# sklearn.cross_decomposition.PLSSVD¶

class sklearn.cross_decomposition.PLSSVD(n_components=2, *, scale=True, copy=True)[source]

Partial Least Square SVD

Simply perform a svd on the crosscovariance matrix: X’Y There are no iterative deflation here.

Read more in the User Guide.

New in version 0.8.

Parameters
n_componentsint, default 2

Number of components to keep.

scaleboolean, default True

Whether to scale X and Y.

copyboolean, default True

Whether to copy X and Y, or perform in-place computations.

Attributes
x_weights_array, [p, n_components]

X block weights vectors.

y_weights_array, [q, n_components]

Y block weights vectors.

x_scores_array, [n_samples, n_components]

X scores.

y_scores_array, [n_samples, n_components]

Y scores.

Examples

>>> import numpy as np
>>> from sklearn.cross_decomposition import PLSSVD
>>> X = np.array([[0., 0., 1.],
...     [1.,0.,0.],
...     [2.,2.,2.],
...     [2.,5.,4.]])
>>> Y = np.array([[0.1, -0.2],
...     [0.9, 1.1],
...     [6.2, 5.9],
...     [11.9, 12.3]])
>>> plsca = PLSSVD(n_components=2)
>>> plsca.fit(X, Y)
PLSSVD()
>>> X_c, Y_c = plsca.transform(X, Y)
>>> X_c.shape, Y_c.shape
((4, 2), (4, 2))


Methods

 fit(X, Y) Fit model to data. fit_transform(X[, y]) Learn and apply the dimension reduction on the train data. get_params([deep]) Get parameters for this estimator. set_params(**params) Set the parameters of this estimator. transform(X[, Y]) Apply the dimension reduction learned on the train data.
__init__(n_components=2, *, scale=True, copy=True)[source]

Initialize self. See help(type(self)) for accurate signature.

fit(X, Y)[source]

Fit model to data.

Parameters
Xarray-like of shape (n_samples, n_features)

Training vectors, where n_samples is the number of samples and n_features is the number of predictors.

Yarray-like of shape (n_samples, n_targets)

Target vectors, where n_samples is the number of samples and n_targets is the number of response variables.

fit_transform(X, y=None)[source]

Learn and apply the dimension reduction on the train data.

Parameters
Xarray-like of shape (n_samples, n_features)

Training vectors, where n_samples is the number of samples and n_features is the number of predictors.

yarray-like of shape (n_samples, n_targets)

Target vectors, where n_samples is the number of samples and n_targets is the number of response variables.

Returns
x_scores if Y is not given, (x_scores, y_scores) otherwise.
get_params(deep=True)[source]

Get parameters for this estimator.

Parameters
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns
paramsmapping of string to any

Parameter names mapped to their values.

set_params(**params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters
**paramsdict

Estimator parameters.

Returns
selfobject

Estimator instance.

transform(X, Y=None)[source]

Apply the dimension reduction learned on the train data.

Parameters
Xarray-like of shape (n_samples, n_features)

Training vectors, where n_samples is the number of samples and n_features is the number of predictors.

Yarray-like of shape (n_samples, n_targets)

Target vectors, where n_samples is the number of samples and n_targets is the number of response variables.