13
13
from scipy .linalg .lapack import get_lapack_funcs
14
14
from joblib import Parallel
15
15
16
- from ._base import LinearModel , _pre_fit
16
+ from ._base import LinearModel , _pre_fit , _deprecate_normalize
17
17
from ..base import RegressorMixin , MultiOutputMixin
18
18
from ..utils import as_float_array , check_array
19
19
from ..utils .fixes import delayed
@@ -616,6 +616,10 @@ class OrthogonalMatchingPursuit(MultiOutputMixin, RegressorMixin, LinearModel):
616
616
:class:`~sklearn.preprocessing.StandardScaler` before calling ``fit``
617
617
on an estimator with ``normalize=False``.
618
618
619
+ .. deprecated:: 1.0
620
+ ``normalize`` was deprecated in version 1.0. It will default
621
+ to False in 1.2 and be removed in 1.4.
622
+
619
623
precompute : 'auto' or bool, default='auto'
620
624
Whether to use a precomputed Gram and Xy matrix to speed up
621
625
calculations. Improves performance when :term:`n_targets` or
@@ -648,7 +652,7 @@ class OrthogonalMatchingPursuit(MultiOutputMixin, RegressorMixin, LinearModel):
648
652
>>> from sklearn.linear_model import OrthogonalMatchingPursuit
649
653
>>> from sklearn.datasets import make_regression
650
654
>>> X, y = make_regression(noise=4, random_state=0)
651
- >>> reg = OrthogonalMatchingPursuit().fit(X, y)
655
+ >>> reg = OrthogonalMatchingPursuit(normalize=False ).fit(X, y)
652
656
>>> reg.score(X, y)
653
657
0.9991...
654
658
>>> reg.predict(X[:1,])
@@ -683,7 +687,7 @@ def __init__(
683
687
n_nonzero_coefs = None ,
684
688
tol = None ,
685
689
fit_intercept = True ,
686
- normalize = True ,
690
+ normalize = "deprecated" ,
687
691
precompute = "auto" ,
688
692
):
689
693
self .n_nonzero_coefs = n_nonzero_coefs
@@ -709,11 +713,15 @@ def fit(self, X, y):
709
713
self : object
710
714
returns an instance of self.
711
715
"""
716
+ _normalize = _deprecate_normalize (
717
+ self .normalize , default = True , estimator_name = self .__class__ .__name__
718
+ )
719
+
712
720
X , y = self ._validate_data (X , y , multi_output = True , y_numeric = True )
713
721
n_features = X .shape [1 ]
714
722
715
723
X , y , X_offset , y_offset , X_scale , Gram , Xy = _pre_fit (
716
- X , y , None , self .precompute , self . normalize , self .fit_intercept , copy = True
724
+ X , y , None , self .precompute , _normalize , self .fit_intercept , copy = True
717
725
)
718
726
719
727
if y .ndim == 1 :
@@ -797,6 +805,10 @@ def _omp_path_residues(
797
805
:class:`~sklearn.preprocessing.StandardScaler` before calling ``fit``
798
806
on an estimator with ``normalize=False``.
799
807
808
+ .. deprecated:: 1.0
809
+ ``normalize`` was deprecated in version 1.0. It will default
810
+ to False in 1.2 and be removed in 1.4.
811
+
800
812
max_iter : int, default=100
801
813
Maximum numbers of iterations to perform, therefore maximum features
802
814
to include. 100 by default.
@@ -872,6 +884,10 @@ class OrthogonalMatchingPursuitCV(RegressorMixin, LinearModel):
872
884
:class:`~sklearn.preprocessing.StandardScaler` before calling ``fit``
873
885
on an estimator with ``normalize=False``.
874
886
887
+ .. deprecated:: 1.0
888
+ ``normalize`` was deprecated in version 1.0. It will default
889
+ to False in 1.2 and be removed in 1.4.
890
+
875
891
max_iter : int, default=None
876
892
Maximum numbers of iterations to perform, therefore maximum features
877
893
to include. 10% of ``n_features`` but at least 5 if available.
@@ -929,7 +945,7 @@ class OrthogonalMatchingPursuitCV(RegressorMixin, LinearModel):
929
945
>>> from sklearn.datasets import make_regression
930
946
>>> X, y = make_regression(n_features=100, n_informative=10,
931
947
... noise=4, random_state=0)
932
- >>> reg = OrthogonalMatchingPursuitCV(cv=5).fit(X, y)
948
+ >>> reg = OrthogonalMatchingPursuitCV(cv=5, normalize=False ).fit(X, y)
933
949
>>> reg.score(X, y)
934
950
0.9991...
935
951
>>> reg.n_nonzero_coefs_
@@ -956,7 +972,7 @@ def __init__(
956
972
* ,
957
973
copy = True ,
958
974
fit_intercept = True ,
959
- normalize = True ,
975
+ normalize = "deprecated" ,
960
976
max_iter = None ,
961
977
cv = None ,
962
978
n_jobs = None ,
@@ -986,6 +1002,11 @@ def fit(self, X, y):
986
1002
self : object
987
1003
returns an instance of self.
988
1004
"""
1005
+
1006
+ _normalize = _deprecate_normalize (
1007
+ self .normalize , default = True , estimator_name = self .__class__ .__name__
1008
+ )
1009
+
989
1010
X , y = self ._validate_data (
990
1011
X , y , y_numeric = True , ensure_min_features = 2 , estimator = self
991
1012
)
@@ -1004,7 +1025,7 @@ def fit(self, X, y):
1004
1025
y [test ],
1005
1026
self .copy ,
1006
1027
self .fit_intercept ,
1007
- self . normalize ,
1028
+ _normalize ,
1008
1029
max_iter ,
1009
1030
)
1010
1031
for train , test in cv .split (X )
@@ -1019,7 +1040,7 @@ def fit(self, X, y):
1019
1040
omp = OrthogonalMatchingPursuit (
1020
1041
n_nonzero_coefs = best_n_nonzero_coefs ,
1021
1042
fit_intercept = self .fit_intercept ,
1022
- normalize = self . normalize ,
1043
+ normalize = _normalize ,
1023
1044
)
1024
1045
omp .fit (X , y )
1025
1046
self .coef_ = omp .coef_
0 commit comments