-
-
Notifications
You must be signed in to change notification settings - Fork 26k
Closed
Labels
Description
Description
SparsePCA
and MiniBatchSparsePCA
will output different results on the method transform
if it is applied on all the data or a subset. This issue follows from the PR #10428
Steps/Code to Reproduce
import numpy as np
from sklearn.decomposition import SparsePCA
rnd = np.random.RandomState(0)
X = 2 * rnd.uniform(size=(5, 2))
y = X[:, 0].astype(np.int)
spca = SparsePCA()
spca.fit(X,y)
res_all = spca.transform(X)
res_one = np.array([spca.transform(X[i].reshape(1, X.shape[1]))[0]
for i in range(X.shape[0])])
print(res_all)
print(res_one)
Expected Results
res_one = res_all
Actual Results
[[-0.48574184 -0.39159711]
[-0.3700734 -0.43009217]
[-0.43867793 -0.30229211]
[-0.60567379 -0.31223336]
[-0.26042556 -0.68760616]]
[[-1. -1.]
[-1. -1.]
[-1. -1.]
[-1. -1.]
[-1. -1.]]
Versions
Linux-4.10.0-42-generic-x86_64-with-debian-stretch-sid
Python 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 13:09:58)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
NumPy 1.12.1
SciPy 0.19.0
Scikit-Learn 0.19.1