Documentation
Classes
CCA

CCA

Canonical Correlation Analysis, also known as “Mode B” PLS.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new CCA(opts?: object): CCA;

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

CCA

Defined in: generated/cross_decomposition/CCA.ts:23 (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/CCA.ts:119 (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/CCA.ts:136 (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/CCA.ts:175 (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/CCA.ts:217 (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/CCA.ts:252 (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/CCA.ts:76 (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/CCA.ts:285 (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/CCA.ts:325 (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/CCA.ts:369 (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/CCA.ts:418 (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/CCA.ts:455 (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/CCA.ts:492 (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/CCA.ts:529 (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/CCA.ts:562 (opens in a new tab)

Properties

_isDisposed

boolean = false

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

_isInitialized

boolean = false

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

_py

PythonBridge

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

id

string

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

opts

any

Defined in: generated/cross_decomposition/CCA.ts:17 (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/CCA.ts:747 (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/CCA.ts:836 (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/CCA.ts:769 (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/CCA.ts:813 (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/CCA.ts:791 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/cross_decomposition/CCA.ts:63 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/cross_decomposition/CCA.ts:67 (opens in a new tab)

x_loadings_

The loadings of X.

Signature

x_loadings_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/CCA.ts:655 (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/CCA.ts:701 (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/CCA.ts:611 (opens in a new tab)

y_loadings_

The loadings of Y.

Signature

y_loadings_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cross_decomposition/CCA.ts:678 (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/CCA.ts:724 (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/CCA.ts:633 (opens in a new tab)