@@ -412,7 +412,6 @@ def dict_learning(X, n_components, alpha, max_iter=100, tol=1e-8,
412
412
SparsePCA
413
413
MiniBatchSparsePCA
414
414
"""
415
-
416
415
if method not in ('lars' , 'cd' ):
417
416
raise ValueError ('Coding method %r not supported as a fit algorithm.'
418
417
% method )
@@ -604,6 +603,8 @@ def dict_learning_online(X, n_components=2, alpha=1, n_iter=100,
604
603
MiniBatchSparsePCA
605
604
606
605
"""
606
+ if n_components is None :
607
+ n_components = X .shape [1 ]
607
608
608
609
if method not in ('lars' , 'cd' ):
609
610
raise ValueError ('Coding method not supported as a fit algorithm.' )
@@ -750,7 +751,7 @@ def transform(self, X, y=None):
750
751
Transformed data
751
752
752
753
"""
753
- check_is_fitted (self , 'components_' )
754
+ check_is_fitted (self , 'components_' )
754
755
755
756
# XXX : kwargs is not documented
756
757
X = check_array (X )
@@ -1159,13 +1160,9 @@ def fit(self, X, y=None):
1159
1160
"""
1160
1161
random_state = check_random_state (self .random_state )
1161
1162
X = check_array (X )
1162
- if self .n_components is None :
1163
- n_components = X .shape [1 ]
1164
- else :
1165
- n_components = self .n_components
1166
1163
1167
1164
U , (A , B ), self .n_iter_ = dict_learning_online (
1168
- X , n_components , self .alpha ,
1165
+ X , self . n_components , self .alpha ,
1169
1166
n_iter = self .n_iter , return_code = False ,
1170
1167
method = self .fit_algorithm ,
1171
1168
n_jobs = self .n_jobs , dict_init = self .dict_init ,
0 commit comments