You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using the sklearn package recently for some simple clustering. It appears to me that there is a typo in the BisectingKMeans class. In the _inertia_per_cluster method, we need to compute the inertia per-cluster. However, in the current version of the package we have the following:
This will through an error unless the centers form a squared matrix, i.e. if we have the same number of clusters as we have scalar features... In order to solve this, we could simply replace the line 276 in the corresponding file with:
inertia_per_cluster=np.empty(centers.shape[0]) # <- instead of [1]
Thanks for the report @EdouardYvinec. To be more precise, this function is only called after a bisection so there are always exactly 2 clusters, meaning that the issue only happens when n_features=1. I opened #27243 to fix it.
Activity
jeremiedbb commentedon Aug 30, 2023
Thanks for the report @EdouardYvinec. To be more precise, this function is only called after a bisection so there are always exactly 2 clusters, meaning that the issue only happens when n_features=1. I opened #27243 to fix it.