/expectation-maximization

Primary LanguageJavaScriptMIT LicenseMIT

expectation-maximization

NPM version build status David deps npm download

Gaussian Mixture Models using Expectation Maximization algorithm transcribed from Expectation Maximization repository of Ophir LOJKINE, also using his multivariate gaussian link.

Installation

$ npm install ml-expectation-maximization

Example

const ExpectationMaximization = require('ml-expectation-maximization').ExpectationMaximization;
const em = new ExpectationMaximization();
em.train(data); // data is a training matrix
em.predict(toPredict); // data matrix to predict

/*
Get information about clusters obtained on the training step.
Each element of the array is a cluster with the following information

* weight: Weight of the current cluster.
* mean: Current mean of the cluster.
* covariance: Covariance matrix of the cluster.
* prediction: prediction label associated with the cluster.
*/
var data = em.getClusterData();

// save your model
var model = em.toJSON();

// load your model
var newEM = EM.load(model);

License

MIT