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
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.copy? | boolean | Whether 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? | number | The maximum number of iterations of the power method when algorithm='nipals' . Ignored otherwise. Default Value 500 |
opts.n_components? | number | Number of components to keep. Should be in \[1, min(n\_samples, n\_features, n\_targets)\] . Default Value 2 |
opts.scale? | boolean | Whether to scale X and Y . Default Value true |
opts.tol? | number | The 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
Defined in: generated/cross_decomposition/PLSRegression.ts:25 (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
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:747 (opens in a new tab)
intercept_
The intercepts of the linear model such that Y
is approximated as Y \= X @ coef\_ + intercept\_
.
Signature
intercept_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/cross_decomposition/PLSRegression.ts:674 (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:722 (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:699 (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
Name | Type |
---|---|
pythonBridge | PythonBridge |
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:524 (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:624 (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:574 (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:474 (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:549 (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:649 (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:599 (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:499 (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
Name | Type | Description |
---|---|---|
opts | object | - |
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
<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
Name | Type | Description |
---|---|---|
opts | object | - |
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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.input_features? | any | Only 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)
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
Name | Type |
---|---|
py | PythonBridge |
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
Name | Type | Description |
---|---|---|
opts | object | - |
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:257 (opens in a new tab)
predict()
Predict targets of given samples.
Signature
predict(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Samples. |
opts.copy? | boolean | Whether to copy X and Y , or perform in-place normalization. Default Value true |
Returns
Promise
<ArrayLike
>
Defined in: generated/cross_decomposition/PLSRegression.ts:299 (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
Name | Type | Description |
---|---|---|
opts | object | - |
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? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | True values for X . |
Returns
Promise
<number
>
Defined in: generated/cross_decomposition/PLSRegression.ts:343 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.transform? | "default" | "pandas" | Configure output of transform and fit\_transform . |
Returns
Promise
<any
>
Defined in: generated/cross_decomposition/PLSRegression.ts:392 (opens in a new tab)
transform()
Apply the dimension reduction.
Signature
transform(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Samples to transform. |
opts.Y? | ArrayLike [] | Target vectors. |
opts.copy? | boolean | Whether to copy X and Y , or perform in-place normalization. Default Value true |
Returns
Promise
<any
>
Defined in: generated/cross_decomposition/PLSRegression.ts:425 (opens in a new tab)