Class: PLSCanonical

Partial Least Squares transformer and regressor.

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

Read more in the User Guide.

Python Reference

Constructors

new PLSCanonical()

new PLSCanonical(opts?): PLSCanonical

Parameters

ParameterTypeDescription
opts?object-
opts.algorithm?"nipals" | "svd"The algorithm used to estimate the first singular vectors of the cross-covariance matrix. ‘nipals’ uses the power method while ‘svd’ will compute the whole SVD.
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, min(n_samples, n_features, n_targets)\].
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 PLSCanonical

Defined in generated/cross_decomposition/PLSCanonical.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/cross_decomposition/PLSCanonical.ts:23
_isInitializedbooleanfalsegenerated/cross_decomposition/PLSCanonical.ts:22
_pyPythonBridgeundefinedgenerated/cross_decomposition/PLSCanonical.ts:21
idstringundefinedgenerated/cross_decomposition/PLSCanonical.ts:18
optsanyundefinedgenerated/cross_decomposition/PLSCanonical.ts:19

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/PLSCanonical.ts:766


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/PLSCanonical.ts:862


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/PLSCanonical.ts:789


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/PLSCanonical.ts:837


n_iter_

Get Signature

get n_iter_(): Promise<any[]>

Number of iterations of the power method, for each component. Empty if algorithm='svd'.

Returns Promise<any[]>

Defined in generated/cross_decomposition/PLSCanonical.ts:814


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/cross_decomposition/PLSCanonical.ts:72


x_loadings_

Get Signature

get x_loadings_(): Promise<ArrayLike[]>

The loadings of X.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSCanonical.ts:666


x_rotations_

Get Signature

get x_rotations_(): Promise<ArrayLike[]>

The projection matrix used to transform X.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSCanonical.ts:716


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/PLSCanonical.ts:616


y_loadings_

Get Signature

get y_loadings_(): Promise<ArrayLike[]>

The loadings of Y.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSCanonical.ts:691


y_rotations_

Get Signature

get y_rotations_(): Promise<ArrayLike[]>

The projection matrix used to transform Y.

Returns Promise<ArrayLike[]>

Defined in generated/cross_decomposition/PLSCanonical.ts:741


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/PLSCanonical.ts:641

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/PLSCanonical.ts:124


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/PLSCanonical.ts:141


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/PLSCanonical.ts:183


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/PLSCanonical.ts:222


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/PLSCanonical.ts:258


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/PLSCanonical.ts:85


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/PLSCanonical.ts:292


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/PLSCanonical.ts:336


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/PLSCanonical.ts:377


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/PLSCanonical.ts:421


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/PLSCanonical.ts:457


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/PLSCanonical.ts:495


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/PLSCanonical.ts:533


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/PLSCanonical.ts:567