Documentation
Classes
PLSRegression

PLSRegression

PLS regression.

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

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new PLSRegression(opts?: object): PLSRegression;

Parameters

NameTypeDescription
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. Default Value true
opts.max_iter?numberThe maximum number of iterations of the power method when algorithm='nipals'. Ignored otherwise. Default Value 500
opts.n_components?numberNumber of components to keep. Should be in \[1, min(n\_samples, n\_features, n\_targets)\]. Default Value 2
opts.scale?booleanWhether to scale X and Y. Default Value true
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. Default Value 0.000001

Returns

PLSRegression

Defined in: generated/cross_decomposition/PLSRegression.ts:25 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

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

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/cross_decomposition/PLSRegression.ts:122 (opens in a new tab)

fit()

Fit model to data.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
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.

Returns

Promise<any>

Defined in: generated/cross_decomposition/PLSRegression.ts:139 (opens in a new tab)

fit_transform()

Learn and apply the dimension reduction on the train data.

Signature

fit_transform(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
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:179 (opens in a new tab)

get_feature_names_out()

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"\].

Signature

get_feature_names_out(opts: object): Promise<any>;

Parameters

NameTypeDescription
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:221 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/cross_decomposition/PLSRegression.ts:259 (opens in a new tab)

init()

Initializes the underlying Python resources.

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

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/cross_decomposition/PLSRegression.ts:78 (opens in a new tab)

inverse_transform()

Transform data back to its original space.

Signature

inverse_transform(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
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?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:294 (opens in a new tab)

predict()

Predict targets of given samples.

Signature

predict(opts: object): Promise<ArrayLike>;

Parameters

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

Returns

Promise<ArrayLike>

Defined in: generated/cross_decomposition/PLSRegression.ts:336 (opens in a new tab)

score()

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.

Signature

score(opts: object): Promise<number>;

Parameters

NameTypeDescription
optsobject-
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.sample_weight?ArrayLikeSample weights.
opts.y?ArrayLikeTrue values for X.

Returns

Promise<number>

Defined in: generated/cross_decomposition/PLSRegression.ts:380 (opens in a new tab)

set_output()

Set output container.

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

Signature

set_output(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.transform?"default" | "pandas"Configure output of transform and fit\_transform.

Returns

Promise<any>

Defined in: generated/cross_decomposition/PLSRegression.ts:429 (opens in a new tab)

set_predict_request()

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:

Signature

set_predict_request(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/cross_decomposition/PLSRegression.ts:466 (opens in a new tab)

set_score_request()

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:

Signature

set_score_request(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in score.

Returns

Promise<any>

Defined in: generated/cross_decomposition/PLSRegression.ts:505 (opens in a new tab)

set_transform_request()

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:

Signature

set_transform_request(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/cross_decomposition/PLSRegression.ts:544 (opens in a new tab)

transform()

Apply the dimension reduction.

Signature

transform(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/cross_decomposition/PLSRegression.ts:579 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/cross_decomposition/PLSRegression.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/cross_decomposition/PLSRegression.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/cross_decomposition/PLSRegression.ts:21 (opens in a new tab)

id

string

Defined in: generated/cross_decomposition/PLSRegression.ts:18 (opens in a new tab)

opts

any

Defined in: generated/cross_decomposition/PLSRegression.ts:19 (opens in a new tab)

Accessors

coef_

The coefficients of the linear model such that Y is approximated as Y \= X @ coef\_.T + intercept\_.

Signature

coef_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSRegression.ts:828 (opens in a new tab)

feature_names_in_

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

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/cross_decomposition/PLSRegression.ts:924 (opens in a new tab)

intercept_

The intercepts of the linear model such that Y is approximated as Y \= X @ coef\_.T + intercept\_.

Signature

intercept_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/cross_decomposition/PLSRegression.ts:851 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/cross_decomposition/PLSRegression.ts:899 (opens in a new tab)

n_iter_

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

Signature

n_iter_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/cross_decomposition/PLSRegression.ts:876 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/cross_decomposition/PLSRegression.ts:65 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/cross_decomposition/PLSRegression.ts:69 (opens in a new tab)

x_loadings_

The loadings of X.

Signature

x_loadings_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSRegression.ts:678 (opens in a new tab)

x_rotations_

The projection matrix used to transform X.

Signature

x_rotations_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSRegression.ts:778 (opens in a new tab)

x_scores_

The transformed training samples.

Signature

x_scores_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSRegression.ts:728 (opens in a new tab)

x_weights_

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

Signature

x_weights_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSRegression.ts:628 (opens in a new tab)

y_loadings_

The loadings of Y.

Signature

y_loadings_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSRegression.ts:703 (opens in a new tab)

y_rotations_

The projection matrix used to transform Y.

Signature

y_rotations_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSRegression.ts:803 (opens in a new tab)

y_scores_

The transformed training targets.

Signature

y_scores_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSRegression.ts:753 (opens in a new tab)

y_weights_

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

Signature

y_weights_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSRegression.ts:653 (opens in a new tab)