Skip to content
Unsupervised machine learning with multivariate Gaussian mixture model which supports both offline data and real-time data stream.
JavaScript HTML CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
example
.gitignore
.travis.yml
LICENSE
README.md
browser.js
build.js build with browserify Jun 13, 2017
index.js
package-lock.json
package.json

README.md

Build Status

Gaussian Mixture Model

Unsupervised machine learning with multivariate Gaussian mixture model which supports both offline data and real-time data stream.

Demo: https://lukapopijac.github.io/gaussian-mixture-model/

Installation

npm install gaussian-mixture-model

Usage

In Node.js, simply require:

const GMM = require('gaussian-mixture-model');

For browser use, include dist/gmm.js file in your project. It will create a global variable GMM.

Simple Example

// initialize model
var gmm = new GMM({
	weights: [0.5, 0.5],
	means: [[-25, 40], [-60, -30]],
	covariances: [
		[[400,0],[0,400]],
		[[400,0],[0,400]]
	]
});

// create some data points
var data = [
	[11,42],[19,45],[15,36],[25,38],[24,33],
	[-24,3],[-31,-4],[-34,-14],[-25,-5],[-16,7]
];

// add data points to the model
data.forEach(p => gmm.addPoint(p));

// run 5 iterations of EM algorithm
gmm.runEM(5);

// predict cluster probabilities for point [-5, 25]
var prob = gmm.predict([-5, 25]);  // [0.000009438559331418772, 0.000002126123537376676]

// predict and normalize cluster probabilities for point [-5, 25]
var probNorm = gmm.predictNormalize([-5, 25]);  // [0.8161537535012295, 0.18384624649877046]

License

This software is released under the MIT license.

You can’t perform that action at this time.