Fix a bug in _k_means.pyx, when KMeans.fit(X.T)#4507
Fix a bug in _k_means.pyx, when KMeans.fit(X.T)#4507zhaipro wants to merge 4 commits intoscikit-learn:masterfrom
Conversation
bad case:
X = np.array([[0, 0, 0], [0, 1, 1]])
estimator = KMeans(n_clusters=2, n_init=1, max_iter=20, \
precompute_distances=False)
estimator.fit(X.T)
print X.T
print estimator.labels_
print estimator.cluster_centers_
print estimator.n_iter_
|
Thanks for the fix. |
|
I didn't check in detail but couldn't there also be a problem if |
|
We could also make sure that X is |
Yes, when I use PCA. X = np.array([[0, 0], [0, 1]])
pca = PCA()
new_X = pca.fit_transform(X)
X.strides
>>> (4, 8)
new_X.strides
>>> (8, 4) |
I think you are right. It also be a problem. |
|
|
|
Indeed this is bad bug. Could you please add a non-regression test on using toy fortran-aligned data by using |
sklearn/cluster/_k_means.pyx
Outdated
There was a problem hiding this comment.
style: please use whitespaces around the / sign.
|
I will perfect it as soon as possible. |
|
@ogrisel the thing is that we should probably add a common test for this, right? |
|
+1 for a common test. |
|
Can you please fix the |
|
@zhaipro have you check that your new test fails when run against the code in the current master? |
|
Could you also please squash your intermediate commits together, ideally keeping one for the |
@ogrisel Yes, I checked. |
|
just force-push the squashed commits into your |
[MRG + 1] squash commits together for #4507
|
Fixed in #4531. |
bad case: