Git Product home page Git Product logo

expectation_maximization's Introduction

Expmax

Statements Branches Functions
Statements Branches Functions

Description

Expmax is an expectation maximization (EM) library. It makes use of a gaussian mixture model.

This library allows data clustering of n-dimensional datasets given the amount of clusters wanted.

Overview

Directory structure

.
├── core
│   ├── expmax_core.ts
│   └── gaussian_mixture_core.ts
├── engines
│   └── expmax.ts
├── errors.ts
├── index.ts
├── types.ts
└── utils
    └── math.ts

How to build the library to be used in production-ready projects?

Please refer to the NPM custom commands section

How to use?

First install the library

npm install expmax

Example:

import {ExpMax} from 'expmax';

// Dataset should have data points with same vector space dimension
const dataset: IDataset = {
    'points': [
        [1.1,1],
        [1,2],
        [2,2],
        [2,1],
        [15,15],
        [15,16],
    ],
    'label':'test',
};

const opts: IEmOptions = {    
    'clusterQt':2, // Quantity of clusters you want to fit
    'maxEpochs':1000, // Maximum training cycles
    'threshold': 2e-16 // Threshold (epsilon) used to define convergence
}

const model = new ExpMax(dataset, opts); // Instanciate the model with random values
const trainedModel = model.train() // Train it
console.log(trainedModel);
/*
Output:
[
  {
    mu: [ 15.55, 16 ],
    sigma: [ [Array], [Array] ],
    vectorSpaceDim: 2,
    pi: 0.3333333333333333,
    gamma: [
      1.8570742387734104e-153,
      3.512200996873401e-50,
      3.128974029587457e-48,
      7.275927146729349e-54,
      1,
      1
    ]
  },
  {
    mu: [ 1.525, 1.5 ],
    sigma: [ [Array], [Array] ],
    vectorSpaceDim: 2,
    pi: 0.6666666666666666,
    gamma: [ 1, 1, 1, 1, 5.362024468745314e-82, 1.955669841306763e-88 ]
  }
]*/

Features

  • .train(): Trains the model then return clusters
  • .update(newDataset): Updates dataset then trains the model and returns new clusters

NPM custom commands

  • build: Build the JavaScript files.
  • build:watch: Build the JavaScript files in watch mode.
  • test: Run jest in test mode.
  • test:watch: Run jest in interactive test mode.
  • docs: Generate the docs directory.
  • lint: Runs linter on the whole project.

Ressources

Credit

@lovasoa: https://github.com/lovasoa/expectation-maximization

This lib helped me a great deal, thanks.

License

License: MIT

Bastien GUIHARD

expectation_maximization's People

Contributors

guihardbastien avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.