@kanaries/ml
API Reference/Cross Decomposition

PLS Regression and CCA

Model two related data blocks with PLSRegression and canonical correlation analysis in JavaScript or TypeScript.

View as Markdown

PLS and CCA

Algorithm overview

Partial least squares finds latent directions that predict a target block, while canonical correlation analysis finds directions with high cross-block correlation. Both help with correlated, multivariate features.

JavaScript implementation

PLSRegression uses mode-A NIPALS with regression deflation. CCA uses mode-B weights with canonical deflation.

Interactive PLS regression playground

Change the latent-component count and data distribution below. The visible first target and holdout metrics come from a live multi-output CrossDecomposition.PLSRegression fit.

Live browser model

PLSRegression playground

Adjust the data and model, then click the chart to add a training observation.

Fitted with @kanaries/ml
-3-2-10123-1.9-0.90.11.22.2feature xtarget y
prediction training holdout your points
Train RMSE0.668
Holdout RMSE0.946
Holdout R²-3.467
Custom points0

Quick start

import { CrossDecomposition } from '@kanaries/ml';

const X = [[0, 1], [1, 2], [2, 3], [3, 5]];
const Y = [[1], [2], [4], [7]];
const model = new CrossDecomposition.PLSRegression({ nComponents: 2 });
model.fit(X, Y);
console.log(model.predict([[4, 6]]));

Detailed API reference

Both expose weights, loadings, rotations, iteration counts, transform, and predict.