Skip to content

DOC Ensures that CCA passes numpydoc validation #20504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 20, 2021
1 change: 0 additions & 1 deletion maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"BaggingRegressor",
"BernoulliRBM",
"Birch",
"CCA",
"CalibratedClassifierCV",
"ClassifierChain",
"ColumnTransformer",
Expand Down
35 changes: 25 additions & 10 deletions sklearn/cross_decomposition/_pls.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ def fit(self, X, Y):
Y : array-like of shape (n_samples,) or (n_samples, n_targets)
Target vectors, where `n_samples` is the number of samples and
`n_targets` is the number of response variables.

Returns
-------
self : object
Fitted model.
"""

check_consistent_length(X, Y)
Expand Down Expand Up @@ -372,7 +377,8 @@ def transform(self, X, Y=None, copy=True):

Returns
-------
`x_scores` if `Y` is not given, `(x_scores, y_scores)` otherwise.
x_scores, y_scores : array-like or tuple of array-like
Return `x_scores` if `Y` is not given, `(x_scores, y_scores)` otherwise.
"""
check_is_fitted(self)
X = self._validate_data(X, copy=copy, dtype=FLOAT_DTYPES, reset=False)
Expand Down Expand Up @@ -403,7 +409,8 @@ def inverse_transform(self, X):

Returns
-------
x_reconstructed : array-like of shape (n_samples, n_features)
self : ndarray of shape (n_samples, n_features)
Return the reconstructed array.

Notes
-----
Expand All @@ -430,6 +437,11 @@ def predict(self, X, copy=True):
copy : bool, default=True
Whether to copy `X` and `Y`, or perform in-place normalization.

Returns
-------
y_pred : ndarray of shape (n_samples,) or (n_samples, n_targets)
Returns predicted values.

Notes
-----
This call requires the estimation of a matrix of shape
Expand Down Expand Up @@ -459,7 +471,8 @@ def fit_transform(self, X, y=None):

Returns
-------
x_scores if Y is not given, (x_scores, y_scores) otherwise.
self : ndarray of shape (n_samples, n_components)
Return `x_scores` if `Y` is not given, `(x_scores, y_scores)` otherwise.
"""
return self.fit(X, y).transform(X, y)

Expand Down Expand Up @@ -506,6 +519,7 @@ def y_std_(self):

@property
def x_scores_(self):
"""Attribute `x_scores_` was deprecated in version 0.24."""
# TODO: raise error in 1.1 instead
if not isinstance(self, PLSRegression):
pass
Expand All @@ -519,6 +533,7 @@ def x_scores_(self):

@property
def y_scores_(self):
"""Attribute `y_scores_` was deprecated in version 0.24."""
# TODO: raise error in 1.1 instead
if not isinstance(self, PLSRegression):
warnings.warn(
Expand Down Expand Up @@ -782,7 +797,7 @@ class CCA(_PLS):
Whether to scale `X` and `Y`.

max_iter : int, default=500
the maximum number of iterations of the power method.
The maximum number of iterations of the power method.

tol : float, default=1e-06
The tolerance used as convergence criteria in the power method: the
Expand Down Expand Up @@ -843,6 +858,11 @@ class CCA(_PLS):
n_features_in_ : int
Number of features seen during :term:`fit`.

See Also
--------
PLSCanonical : Partial Least Squares transformer and regressor.
PLSSVD : Partial Least Square SVD.

Examples
--------
>>> from sklearn.cross_decomposition import CCA
Expand All @@ -852,11 +872,6 @@ class CCA(_PLS):
>>> cca.fit(X, Y)
CCA(n_components=1)
>>> X_c, Y_c = cca.transform(X, Y)

See Also
--------
PLSCanonical
PLSSVD
"""

def __init__(
Expand Down Expand Up @@ -1078,7 +1093,7 @@ def transform(self, X, Y=None):

Returns
-------
out : array-like or tuple of array-like
x_scores : array-like or tuple of array-like
The transformed data `X_tranformed` if `Y` is not None,
`(X_transformed, Y_transformed)` otherwise.
"""
Expand Down