Skip to content

DOC Ensures that PLSSVD passes numpydoc validation #21198

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 3 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"OrthogonalMatchingPursuit",
"OrthogonalMatchingPursuitCV",
"PLSRegression",
"PLSSVD",
"PassiveAggressiveClassifier",
"PassiveAggressiveRegressor",
"PatchExtractor",
Expand Down
33 changes: 19 additions & 14 deletions sklearn/cross_decomposition/_pls.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,10 +910,10 @@ def __init__(
class PLSSVD(TransformerMixin, BaseEstimator):
"""Partial Least Square SVD.

This transformer simply performs a SVD on the crosscovariance matrix X'Y.
It is able to project both the training data `X` and the targets `Y`. The
training data X is projected on the left singular vectors, while the
targets are projected on the right singular vectors.
This transformer simply performs a SVD on the cross-covariance matrix
`X'Y`. It is able to project both the training data `X` and the targets
`Y`. The training data `X` is projected on the left singular vectors, while
the targets are projected on the right singular vectors.

Read more in the :ref:`User Guide <cross_decomposition>`.

Expand All @@ -930,18 +930,18 @@ class PLSSVD(TransformerMixin, BaseEstimator):

copy : bool, default=True
Whether to copy `X` and `Y` in fit before applying centering, and
potentially scaling. If False, these operations will be done inplace,
potentially scaling. If `False`, these operations will be done inplace,
modifying both arrays.

Attributes
----------
x_weights_ : ndarray of shape (n_features, n_components)
The left singular vectors of the SVD of the cross-covariance matrix.
Used to project `X` in `transform`.
Used to project `X` in :meth:`transform`.

y_weights_ : ndarray of (n_targets, n_components)
The right singular vectors of the SVD of the cross-covariance matrix.
Used to project `X` in `transform`.
Used to project `X` in :meth:`transform`.

x_scores_ : ndarray of shape (n_samples, n_components)
The transformed training samples.
Expand All @@ -968,6 +968,11 @@ class PLSSVD(TransformerMixin, BaseEstimator):

.. versionadded:: 1.0

See Also
--------
PLSCanonical : Partial Least Squares transformer and regressor.
CCA : Canonical Correlation Analysis.

Examples
--------
>>> import numpy as np
Expand All @@ -984,11 +989,6 @@ class PLSSVD(TransformerMixin, BaseEstimator):
>>> X_c, Y_c = pls.transform(X, Y)
>>> X_c.shape, Y_c.shape
((4, 2), (4, 2))

See Also
--------
PLSCanonical
CCA
"""

def __init__(self, n_components=2, *, scale=True, copy=True):
Expand All @@ -1006,6 +1006,11 @@ def fit(self, X, Y):

Y : array-like of shape (n_samples,) or (n_samples, n_targets)
Targets.

Returns
-------
self : object
Fitted estimator.
"""
check_consistent_length(X, Y)
X = self._validate_data(
Expand Down Expand Up @@ -1118,7 +1123,7 @@ def transform(self, X, Y=None):
Returns
-------
x_scores : array-like or tuple of array-like
The transformed data `X_tranformed` if `Y` is not None,
The transformed data `X_tranformed` if `Y is not None`,
`(X_transformed, Y_transformed)` otherwise.
"""
check_is_fitted(self)
Expand Down Expand Up @@ -1149,7 +1154,7 @@ def fit_transform(self, X, y=None):
Returns
-------
out : array-like or tuple of array-like
The transformed data `X_tranformed` if `Y` is not None,
The transformed data `X_tranformed` if `Y is not None`,
`(X_transformed, Y_transformed)` otherwise.
"""
return self.fit(X, y).transform(X, y)