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
After #16224 it looks like this code no longer produces the correct result:
import numpy as np
from sklearn.decomposition import PCA
n_samples, n_dim = 1000, 10
X = np.random.RandomState(0).randn(n_samples, n_dim)
X[:, -1] = np.mean(X[:, :-1], axis=-1) # true X dim is ndim - 1
pca_skl = PCA('mle', svd_solver='full')
pca_skl.fit(X)
assert pca_skl.n_components_ == n_dim - 1
Before #16224 this passed (n_components_ == 9) but after #16224 it gives 8. Not sure why this would happen given the singular value spectrum looks good:
import matplotlib.pyplot as plt
s = np.linalg.svdvals(X)
plt.stem(s)
So I'm not entirely sure but it's likely that it's related to what we're also discussing in this thread.
@Reksbril from my side I'm a bit stuck, so if you have any ideas go for it :)
It definitely seems to have introduced a worse bug that what was fixed. What @larsoner reported will probably affect many more users. If no fix can be found in a reasonable time, I think we should revert.
Activity
gorski-m commentedon Mar 26, 2020
Can I work on this?
lschwetlick commentedon Mar 26, 2020
So I'm not entirely sure but it's likely that it's related to what we're also discussing in this thread.
@Reksbril from my side I'm a bit stuck, so if you have any ideas go for it :)
NicolasHug commentedon Apr 1, 2020
Thanks for the report @larsoner
@adrinjalali @jnothman should we temporarily revert the changes introduced in #16224?
Slightly related, the fact that we allow
n_components=0(which returns an empty array) sounds like a bug to meadrinjalali commentedon Apr 1, 2020
I don't think reverting that PR would be a good idea, since it's fixing an issue itself (we could exclude it from the release though).
cc'ing @agramfort
NicolasHug commentedon Apr 1, 2020
It definitely seems to have introduced a worse bug that what was fixed. What @larsoner reported will probably affect many more users. If no fix can be found in a reasonable time, I think we should revert.