Documentation
Classes
PLSCanonical

PLSCanonical

Partial Least Squares transformer and regressor.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new PLSCanonical(opts?: object): PLSCanonical;

Parameters

NameTypeDescription
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. Default Value 'nipals'
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

PLSCanonical

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

Properties

_isDisposed

boolean = false

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

_isInitialized

boolean = false

Defined in: generated/cross_decomposition/PLSCanonical.ts:20 (opens in a new tab)

_py

PythonBridge

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

id

string

Defined in: generated/cross_decomposition/PLSCanonical.ts:16 (opens in a new tab)

opts

any

Defined in: generated/cross_decomposition/PLSCanonical.ts:17 (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/PLSCanonical.ts:702 (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/PLSCanonical.ts:629 (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/PLSCanonical.ts:677 (opens in a new tab)

n_iter_

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

Signature

n_iter_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/cross_decomposition/PLSCanonical.ts:654 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/cross_decomposition/PLSCanonical.ts:70 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/cross_decomposition/PLSCanonical.ts:74 (opens in a new tab)

x_loadings_

The loadings of X.

Signature

x_loadings_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSCanonical.ts:529 (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/PLSCanonical.ts:579 (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/PLSCanonical.ts:479 (opens in a new tab)

y_loadings_

The loadings of Y.

Signature

y_loadings_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/PLSCanonical.ts:554 (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/PLSCanonical.ts:604 (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/PLSCanonical.ts:504 (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/PLSCanonical.ts:127 (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/PLSCanonical.ts:144 (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/PLSCanonical.ts:184 (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/PLSCanonical.ts:226 (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/PLSCanonical.ts:83 (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/PLSCanonical.ts:262 (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/PLSCanonical.ts:304 (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/PLSCanonical.ts:348 (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/PLSCanonical.ts:397 (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/PLSCanonical.ts:430 (opens in a new tab)