Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb38539

Browse files
njkevlanirth
authored andcommitted
[MRG+1] Added _fit_svd_solver variable to PCA (#11225)
1 parent bd19a84 commit bb38539

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

sklearn/decomposition/pca.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,25 +389,25 @@ def _fit(self, X):
389389
n_components = self.n_components
390390

391391
# Handle svd_solver
392-
svd_solver = self.svd_solver
393-
if svd_solver == 'auto':
392+
self._fit_svd_solver = self.svd_solver
393+
if self._fit_svd_solver == 'auto':
394394
# Small problem or n_components == 'mle', just call full PCA
395395
if max(X.shape) <= 500 or n_components == 'mle':
396-
svd_solver = 'full'
396+
self._fit_svd_solver = 'full'
397397
elif n_components >= 1 and n_components < .8 * min(X.shape):
398-
svd_solver = 'randomized'
398+
self._fit_svd_solver = 'randomized'
399399
# This is also the case of n_components in (0,1)
400400
else:
401-
svd_solver = 'full'
401+
self._fit_svd_solver = 'full'
402402

403403
# Call different fits for either full or truncated SVD
404-
if svd_solver == 'full':
404+
if self._fit_svd_solver == 'full':
405405
return self._fit_full(X, n_components)
406-
elif svd_solver in ['arpack', 'randomized']:
407-
return self._fit_truncated(X, n_components, svd_solver)
406+
elif self._fit_svd_solver in ['arpack', 'randomized']:
407+
return self._fit_truncated(X, n_components, self._fit_svd_solver)
408408
else:
409409
raise ValueError("Unrecognized svd_solver='{0}'"
410-
"".format(svd_solver))
410+
"".format(self._fit_svd_solver))
411411

412412
def _fit_full(self, X, n_components):
413413
"""Fit the model by computing full SVD on X"""

0 commit comments

Comments
 (0)