Class: PLSRegression

PLS regression.

PLSRegression is also known as PLS2 or PLS1, depending on the number of targets.

For a comparison between other cross decomposition algorithms, see Compare cross decomposition methods.

Read more in the User Guide.

Python Reference

Constructors

new PLSRegression()

new PLSRegression(opts?): PLSRegression

Parameters

ParameterTypeDescription
opts?object-
opts.copy?booleanWhether to copy X and Y in fit before applying centering, and potentially scaling. If false, these operations will be done inplace, modifying both arrays.
opts.max_iter?numberThe maximum number of iterations of the power method when algorithm='nipals'. Ignored otherwise.
opts.n_components?numberNumber of components to keep. Should be in \[1, n_features\].
opts.scale?booleanWhether to scale X and Y.
opts.tol?numberThe tolerance used as convergence criteria in the power method: the algorithm stops whenever the squared norm of u_i \- u_{i-1} is less than tol, where u corresponds to the left singular vector.

Returns PLSRegression

Defined in generated/cross_decomposition/PLSRegression.ts:27

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/cross_decomposition/PLSRegression.ts:25
_isInitializedbooleanfalsegenerated/cross_decomposition/PLSRegression.ts:24
_pyPythonBridgeundefinedgenerated/cross_decomposition/PLSRegression.ts:23
idstringundefinedgenerated/cross_decomposition/PLSRegression.ts:20
optsanyundefinedgenerated/cross_decomposition/PLSRegression.ts:21

Accessors

coef_

Get Signature

get coef_(): Promise<ArrayLike[]>

The coefficients of the linear model such that Y is approximated as Y \= X @ coef_.T + intercept_.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:811


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

Names of features seen during fit. Defined only when X has feature names that are all strings.

Returns Promise<ArrayLike>

Defined in generated/cross_decomposition/PLSRegression.ts:907


intercept_

Get Signature

get intercept_(): Promise<ArrayLike>

The intercepts of the linear model such that Y is approximated as Y \= X @ coef_.T + intercept_.

Returns Promise<ArrayLike>

Defined in generated/cross_decomposition/PLSRegression.ts:834


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/cross_decomposition/PLSRegression.ts:882


n_iter_

Get Signature

get n_iter_(): Promise<any[]>

Number of iterations of the power method, for each component.

Returns Promise<any[]>

Defined in generated/cross_decomposition/PLSRegression.ts:859


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/cross_decomposition/PLSRegression.ts:67


x_loadings_

Get Signature

get x_loadings_(): Promise<ArrayLike[]>

The loadings of X.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:661


x_rotations_

Get Signature

get x_rotations_(): Promise<ArrayLike[]>

The projection matrix used to transform X.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:761


x_scores_

Get Signature

get x_scores_(): Promise<ArrayLike[]>

The transformed training samples.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:711


x_weights_

Get Signature

get x_weights_(): Promise<ArrayLike[]>

The left singular vectors of the cross-covariance matrices of each iteration.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:611


y_loadings_

Get Signature

get y_loadings_(): Promise<ArrayLike[]>

The loadings of Y.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:686


y_rotations_

Get Signature

get y_rotations_(): Promise<ArrayLike[]>

The projection matrix used to transform Y.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:786


y_scores_

Get Signature

get y_scores_(): Promise<ArrayLike[]>

The transformed training targets.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:736


y_weights_

Get Signature

get y_weights_(): Promise<ArrayLike[]>

The right singular vectors of the cross-covariance matrices of each iteration.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:636

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/cross_decomposition/PLSRegression.ts:119


fit()

fit(opts): Promise<any>

Fit model to data.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training vectors, where n_samples is the number of samples and n_features is the number of predictors.
opts.y?ArrayLikeTarget vectors, where n_samples is the number of samples and n_targets is the number of response variables.
opts.Y?ArrayLikeTarget vectors, where n_samples is the number of samples and n_targets is the number of response variables.

Returns Promise<any>

Defined in generated/cross_decomposition/PLSRegression.ts:136


fit_transform()

fit_transform(opts): Promise<ArrayLike[]>

Learn and apply the dimension reduction on the train data.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training vectors, where n_samples is the number of samples and n_features is the number of predictors.
opts.y?ArrayLike[]Target vectors, where n_samples is the number of samples and n_targets is the number of response variables.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:178


get_feature_names_out()

get_feature_names_out(opts): Promise<any>

Get output feature names for transformation.

The feature names out will prefixed by the lowercased class name. For example, if the transformer outputs 3 features, then the feature names out are: \["class_name0", "class_name1", "class_name2"\].

Parameters

ParameterTypeDescription
optsobject-
opts.input_features?anyOnly used to validate feature names with the names seen in fit.

Returns Promise<any>

Defined in generated/cross_decomposition/PLSRegression.ts:217


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns Promise<any>

Defined in generated/cross_decomposition/PLSRegression.ts:253


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/cross_decomposition/PLSRegression.ts:80


inverse_transform()

inverse_transform(opts): Promise<ArrayLike[]>

Transform data back to its original space.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]New data, where n_samples is the number of samples and n_components is the number of pls components.
opts.y?ArrayLikeNew target, where n_samples is the number of samples and n_components is the number of pls components.
opts.Y?ArrayLike[]New target, where n_samples is the number of samples and n_components is the number of pls components.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSRegression.ts:287


predict()

predict(opts): Promise<ArrayLike>

Predict targets of given samples.

Parameters

ParameterTypeDescription
optsobject-
opts.copy?booleanWhether to copy X and Y, or perform in-place normalization.
opts.X?ArrayLike[]Samples.

Returns Promise<ArrayLike>

Defined in generated/cross_decomposition/PLSRegression.ts:331


score()

score(opts): Promise<number>

Return the coefficient of determination of the prediction.

The coefficient of determination \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true \- y_pred)\*\* 2).sum() and \(v\) is the total sum of squares ((y_true \- y_true.mean()) \*\* 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeSample weights.
opts.X?ArrayLike[]Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
opts.y?ArrayLikeTrue values for X.

Returns Promise<number>

Defined in generated/cross_decomposition/PLSRegression.ts:372


set_output()

set_output(opts): Promise<any>

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters

ParameterTypeDescription
optsobject-
opts.transform?"default" | "pandas" | "polars"Configure output of transform and fit_transform.

Returns Promise<any>

Defined in generated/cross_decomposition/PLSRegression.ts:416


set_predict_request()

set_predict_request(opts): Promise<any>

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.copy?string | booleanMetadata routing for copy parameter in predict.

Returns Promise<any>

Defined in generated/cross_decomposition/PLSRegression.ts:452


set_score_request()

set_score_request(opts): Promise<any>

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in score.

Returns Promise<any>

Defined in generated/cross_decomposition/PLSRegression.ts:490


set_transform_request()

set_transform_request(opts): Promise<any>

Request metadata passed to the transform method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.copy?string | booleanMetadata routing for copy parameter in transform.

Returns Promise<any>

Defined in generated/cross_decomposition/PLSRegression.ts:528


transform()

transform(opts): Promise<any>

Apply the dimension reduction.

Parameters

ParameterTypeDescription
optsobject-
opts.copy?booleanWhether to copy X and Y, or perform in-place normalization.
opts.X?ArrayLike[]Samples to transform.
opts.y?ArrayLike[]Target vectors.
opts.Y?ArrayLike[]Target vectors.

Returns Promise<any>

Defined in generated/cross_decomposition/PLSRegression.ts:562