2
2
# Author: Vlad Niculae, Gael Varoquaux, Alexandre Gramfort
3
3
# License: BSD 3 clause
4
4
5
+ import warnings
6
+
5
7
import numpy as np
6
8
7
9
from ..utils import check_random_state , check_array
@@ -130,7 +132,7 @@ def fit(self, X, y=None):
130
132
self .error_ = E
131
133
return self
132
134
133
- def transform (self , X , ridge_alpha = None ):
135
+ def transform (self , X , ridge_alpha = 'deprecated' ):
134
136
"""Least Squares projection of the data onto the sparse components.
135
137
136
138
To avoid instability issues in case the system is under-determined,
@@ -150,6 +152,10 @@ def transform(self, X, ridge_alpha=None):
150
152
Amount of ridge shrinkage to apply in order to improve
151
153
conditioning.
152
154
155
+ .. deprecated:: 0.19
156
+ This parameter will be removed in 0.21.
157
+ Specify ``ridge_alpha`` in the ``SparsePCA`` constructor.
158
+
153
159
Returns
154
160
-------
155
161
X_new array, shape (n_samples, n_components)
@@ -158,7 +164,15 @@ def transform(self, X, ridge_alpha=None):
158
164
check_is_fitted (self , 'components_' )
159
165
160
166
X = check_array (X )
161
- ridge_alpha = self .ridge_alpha if ridge_alpha is None else ridge_alpha
167
+ if ridge_alpha != 'deprecated' :
168
+ warnings .warn ("The ridge_alpha parameter on transform() is "
169
+ "deprecated since 0.19 and will be removed in 0.21. "
170
+ "Specify ridge_alpha in the SparsePCA constructor." ,
171
+ DeprecationWarning )
172
+ if ridge_alpha is None :
173
+ ridge_alpha = self .ridge_alpha
174
+ else :
175
+ ridge_alpha = self .ridge_alpha
162
176
U = ridge_regression (self .components_ .T , X .T , ridge_alpha ,
163
177
solver = 'cholesky' )
164
178
s = np .sqrt ((U ** 2 ).sum (axis = 0 ))
0 commit comments