@@ -358,6 +358,7 @@ def fit(self, X, Y):
358
358
# TODO(1.3): change `self._coef_` to `self.coef_`
359
359
self ._coef_ = np .dot (self .x_rotations_ , self .y_loadings_ .T )
360
360
self ._coef_ = (self ._coef_ * self ._y_std ).T
361
+ self .intercept_ = self ._y_mean
361
362
self ._n_features_out = self .x_rotations_ .shape [1 ]
362
363
return self
363
364
@@ -473,7 +474,7 @@ def predict(self, X, copy=True):
473
474
X /= self ._x_std
474
475
# TODO(1.3): change `self._coef_` to `self.coef_`
475
476
Ypred = X @ self ._coef_ .T
476
- return Ypred + self ._y_mean
477
+ return Ypred + self .intercept_
477
478
478
479
def fit_transform (self , X , y = None ):
479
480
"""Learn and apply the dimension reduction on the train data.
@@ -501,6 +502,7 @@ def coef_(self):
501
502
# TODO(1.3): remove and change `self._coef_` to `self.coef_`
502
503
# remove catch warnings from `_get_feature_importances`
503
504
# delete self._coef_no_warning
505
+ # update the docstring of `coef_` and `intercept_` attribute
504
506
if hasattr (self , "_coef_" ) and getattr (self , "_coef_warning" , True ):
505
507
warnings .warn (
506
508
"The attribute `coef_` will be transposed in version 1.3 to be "
@@ -581,7 +583,13 @@ class PLSRegression(_PLS):
581
583
582
584
coef_ : ndarray of shape (n_features, n_targets)
583
585
The coefficients of the linear model such that `Y` is approximated as
584
- `Y = X @ coef_`.
586
+ `Y = X @ coef_ + intercept_`.
587
+
588
+ intercept_ : ndarray of shape (n_targets,)
589
+ The intercepts of the linear model such that `Y` is approximated as
590
+ `Y = X @ coef_ + intercept_`.
591
+
592
+ .. versionadded:: 1.1
585
593
586
594
n_iter_ : list of shape (n_components,)
587
595
Number of iterations of the power method, for each
@@ -715,7 +723,13 @@ class PLSCanonical(_PLS):
715
723
716
724
coef_ : ndarray of shape (n_features, n_targets)
717
725
The coefficients of the linear model such that `Y` is approximated as
718
- `Y = X @ coef_`.
726
+ `Y = X @ coef_ + intercept_`.
727
+
728
+ intercept_ : ndarray of shape (n_targets,)
729
+ The intercepts of the linear model such that `Y` is approximated as
730
+ `Y = X @ coef_ + intercept_`.
731
+
732
+ .. versionadded:: 1.1
719
733
720
734
n_iter_ : list of shape (n_components,)
721
735
Number of iterations of the power method, for each
@@ -827,7 +841,13 @@ class CCA(_PLS):
827
841
828
842
coef_ : ndarray of shape (n_features, n_targets)
829
843
The coefficients of the linear model such that `Y` is approximated as
830
- `Y = X @ coef_`.
844
+ `Y = X @ coef_ + intercept_`.
845
+
846
+ intercept_ : ndarray of shape (n_targets,)
847
+ The intercepts of the linear model such that `Y` is approximated as
848
+ `Y = X @ coef_ + intercept_`.
849
+
850
+ .. versionadded:: 1.1
831
851
832
852
n_iter_ : list of shape (n_components,)
833
853
Number of iterations of the power method, for each
0 commit comments