npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

expmax

v0.2.4

Published

Expectation maximization using multivariate gaussian distribution library - clustering lib

Downloads

2

Readme

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

  • https://towardsdatascience.com/gaussian-mixture-models-explained-6986aaf5a95
  • https://perso.telecom-paristech.fr/bonald/documents/gmm.pdf

Credit

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

This lib helped me a great deal, thanks.

License

License: MIT

Bastien GUIHARD