npm

Join us for the upcoming webinar, "Enterprise JavaScript done right: the tools you love, the security you need."Sign up here »

ml-pls

2.0.0 • Public • Published

Partial Least Squares (PLS) and Kernel-based Orthogonal Projections to Latent Structures (K-OPLS)

NPM version build status npm download

PLS regression algorithm based on the Yi Cao implementation:

PLS Matlab code

K-OPLS regression algorithm based on this paper.

K-OPLS Matlab code

installation

$ npm i ml-pls

Usage

PLS

import PLS from 'ml-pls';
 
var X = [[0.1, 0.02], [0.25, 1.01], [0.95, 0.01], [1.01, 0.96]];
var Y = [[1, 0], [1, 0], [1, 0], [0, 1]];
var options = {
  latentVectors: 10,
  tolerance: 1e-4
};
 
var pls = new PLS(options);
pls.train(X, Y);

K-OPLS

// assuming that you created Xtrain, Xtest, Ytrain, Ytest
 
import Kernel from 'ml-kernel';
import KOPLS from 'ml-pls';
 
var kernel = new Kernel('gaussian', {
  sigma: 25
});
 
var cls = new KOPLS({
  orthogonalComponents: 10,
  predictiveComponents: 1,
  kernel: kernel
});
 
cls.train(Xtrain, Ytrain);
var {
  prediction, // prediction
  predScoreMat, // Score matrix over prediction
  predYOrthVectors // Y-Orthogonal vectors over prediction
} = cls.predict(Xtest);

API Documentation

License

MIT

install

npm i ml-pls

Downloadsweekly downloads

172

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability