10
10
import numpy as np
11
11
from scipy import linalg
12
12
13
+ import warnings
14
+
13
15
from .base import LinearModel
14
16
from ..base import RegressorMixin
15
17
from ..utils .extmath import fast_logdet , pinvh
16
18
from ..utils import check_X_y
17
-
19
+ from .. utils import deprecated
18
20
19
21
###############################################################################
20
22
# BayesianRidge regression
@@ -63,8 +65,8 @@ class BayesianRidge(LinearModel, RegressorMixin):
63
65
(e.g. data is expected to be already centered).
64
66
Default is True.
65
67
66
- normalize : boolean, optional, default False
67
- If True, the regressors X will be normalized before regression.
68
+ standardize : boolean, optional, default False
69
+ If True, the regressors X will be standardized before regression.
68
70
69
71
copy_X : boolean, optional, default True
70
72
If True, X will be copied; else, it may be overwritten.
@@ -95,7 +97,7 @@ class BayesianRidge(LinearModel, RegressorMixin):
95
97
... # doctest: +NORMALIZE_WHITESPACE
96
98
BayesianRidge(alpha_1=1e-06, alpha_2=1e-06, compute_score=False,
97
99
copy_X=True, fit_intercept=True, lambda_1=1e-06, lambda_2=1e-06,
98
- n_iter=300, normalize =False, tol=0.001, verbose=False)
100
+ n_iter=300, standardize =False, tol=0.001, verbose=False)
99
101
>>> clf.predict([[1, 1]])
100
102
array([ 1.])
101
103
@@ -106,8 +108,14 @@ class BayesianRidge(LinearModel, RegressorMixin):
106
108
107
109
def __init__ (self , n_iter = 300 , tol = 1.e-3 , alpha_1 = 1.e-6 , alpha_2 = 1.e-6 ,
108
110
lambda_1 = 1.e-6 , lambda_2 = 1.e-6 , compute_score = False ,
109
- fit_intercept = True , normalize = False , copy_X = True ,
110
- verbose = False ):
111
+ fit_intercept = True , normalize = False , standardize = False ,
112
+ copy_X = True , verbose = False ):
113
+ if normalize :
114
+ warnings .warn ("The `normalize` parameter is not in use anymore "
115
+ "from version 0.17 and will be removed in 0.19. If "
116
+ "you want the data to be standardized instead, use "
117
+ "`standardize=True`" , DeprecationWarning )
118
+
111
119
self .n_iter = n_iter
112
120
self .tol = tol
113
121
self .alpha_1 = alpha_1
@@ -116,10 +124,18 @@ def __init__(self, n_iter=300, tol=1.e-3, alpha_1=1.e-6, alpha_2=1.e-6,
116
124
self .lambda_2 = lambda_2
117
125
self .compute_score = compute_score
118
126
self .fit_intercept = fit_intercept
119
- self .normalize = normalize
127
+ self .standardize = standardize
120
128
self .copy_X = copy_X
121
129
self .verbose = verbose
122
130
131
+ @property
132
+ @deprecated ("The `normalize` attribute is not in use anymore "
133
+ "from version 0.17 and will be removed in 0.19. If "
134
+ "you want the data to be standardized instead, use "
135
+ "`standardize=True`" )
136
+ def normalize (self ):
137
+ return None
138
+
123
139
def fit (self , X , y ):
124
140
"""Fit the model
125
141
@@ -136,7 +152,7 @@ def fit(self, X, y):
136
152
"""
137
153
X , y = check_X_y (X , y , dtype = np .float64 , y_numeric = True )
138
154
X , y , X_mean , y_mean , X_std = self ._center_data (
139
- X , y , self .fit_intercept , self .normalize , self .copy_X )
155
+ X , y , self .fit_intercept , self .standardize , self .copy_X )
140
156
n_samples , n_features = X .shape
141
157
142
158
# Initialization of the values of the parameters
@@ -267,8 +283,8 @@ class ARDRegression(LinearModel, RegressorMixin):
267
283
(e.g. data is expected to be already centered).
268
284
Default is True.
269
285
270
- normalize : boolean, optional, default False
271
- If True, the regressors X will be normalized before regression.
286
+ standardize : boolean, optional, default False
287
+ If True, the regressors X will be standardized before regression.
272
288
273
289
copy_X : boolean, optional, default True.
274
290
If True, X will be copied; else, it may be overwritten.
@@ -301,7 +317,7 @@ class ARDRegression(LinearModel, RegressorMixin):
301
317
... # doctest: +NORMALIZE_WHITESPACE
302
318
ARDRegression(alpha_1=1e-06, alpha_2=1e-06, compute_score=False,
303
319
copy_X=True, fit_intercept=True, lambda_1=1e-06, lambda_2=1e-06,
304
- n_iter=300, normalize =False, threshold_lambda=10000.0, tol=0.001,
320
+ n_iter=300, standardize =False, threshold_lambda=10000.0, tol=0.001,
305
321
verbose=False)
306
322
>>> clf.predict([[1, 1]])
307
323
array([ 1.])
@@ -314,11 +330,17 @@ class ARDRegression(LinearModel, RegressorMixin):
314
330
def __init__ (self , n_iter = 300 , tol = 1.e-3 , alpha_1 = 1.e-6 , alpha_2 = 1.e-6 ,
315
331
lambda_1 = 1.e-6 , lambda_2 = 1.e-6 , compute_score = False ,
316
332
threshold_lambda = 1.e+4 , fit_intercept = True , normalize = False ,
317
- copy_X = True , verbose = False ):
333
+ standardize = False , copy_X = True , verbose = False ):
334
+ if normalize :
335
+ warnings .warn ("The `normalize` parameter is not in use anymore "
336
+ "from version 0.17 and will be removed in 0.19. If "
337
+ "you want the data to be standardized instead, use "
338
+ "`standardize=True`" , DeprecationWarning )
339
+
318
340
self .n_iter = n_iter
319
341
self .tol = tol
320
342
self .fit_intercept = fit_intercept
321
- self .normalize = normalize
343
+ self .standardize = standardize
322
344
self .alpha_1 = alpha_1
323
345
self .alpha_2 = alpha_2
324
346
self .lambda_1 = lambda_1
@@ -352,7 +374,7 @@ def fit(self, X, y):
352
374
coef_ = np .zeros (n_features )
353
375
354
376
X , y , X_mean , y_mean , X_std = self ._center_data (
355
- X , y , self .fit_intercept , self .normalize , self .copy_X )
377
+ X , y , self .fit_intercept , self .standardize , self .copy_X )
356
378
357
379
# Launch the convergence loop
358
380
keep_lambda = np .ones (n_features , dtype = bool )
0 commit comments