8000 FIX remove action of normalize_components in SparsePCA by glemaitre · Pull Request #14134 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

FIX remove action of normalize_components in SparsePCA #14134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/whats_new/v0.22.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ parameters, may produce different models from the previous version. This often
occurs due to changes in the modelling logic (bug fixes or enhancements), or in
random sampling procedures.

..
TO FILL IN AS WE GO
- :class:`decomposition.SparsePCA` where `normalize_components` has no effect
due to deprecation.

Details are listed in the changelog below.

Expand Down
9 changes: 1 addition & 8 deletions sklearn/decomposition/sparse_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,11 @@ def transform(self, X):
check_is_fitted(self, 'components_')

X = check_array(X)

if self.normalize_components:
X = X - self.mean_
X = X - self.mean_

U = ridge_regression(self.components_.T, X.T, self.ridge_alpha,
solver='cholesky')

if not self.normalize_components:
s = np.sqrt((U ** 2).sum(axis=0))
s[s == 0] = 1
U /= s

return U


Expand Down
0