Skip to content

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

License

Notifications You must be signed in to change notification settings

lukapopijac/gaussian-mixture-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jan 16, 2025
ab7e6a0 · Jan 16, 2025

History

77 Commits
Jan 16, 2025
Jan 16, 2025
Sep 16, 2023
Sep 16, 2023
Apr 20, 2017
Apr 16, 2017
Sep 16, 2023
Sep 16, 2023

Repository files navigation

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

Simple Example

import GMM from 'gaussian-mixture-model';

// initialize model
let 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
let 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]
let prob = gmm.predict([-5, 25]);  // [0.000009438559331418772, 0.000002126123537376676]

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

License

This software is released under the MIT license.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published