All Projects → Sumolari → hmm

Sumolari / hmm

Licence: MIT license
A Hidden Markov Model implemented in Javascript

Programming Languages

coffeescript
4710 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to hmm

Ml
A high-level machine learning and deep learning library for the PHP language.
Stars: ✭ 1,270 (+4279.31%)
Mutual labels:  clustering, classification
Tiny ml
numpy 实现的 周志华《机器学习》书中的算法及其他一些传统机器学习算法
Stars: ✭ 129 (+344.83%)
Mutual labels:  clustering, classification
Neuroflow
Artificial Neural Networks for Scala
Stars: ✭ 105 (+262.07%)
Mutual labels:  clustering, classification
Weka Jruby
Machine Learning & Data Mining with JRuby
Stars: ✭ 64 (+120.69%)
Mutual labels:  clustering, classification
Ml Course
Starter code of Prof. Andrew Ng's machine learning MOOC in R statistical language
Stars: ✭ 154 (+431.03%)
Mutual labels:  clustering, classification
Tgcontest
Telegram Data Clustering contest solution by Mindful Squirrel
Stars: ✭ 74 (+155.17%)
Mutual labels:  clustering, classification
Ml Dl Scripts
The repository provides usefull python scripts for ML and data analysis
Stars: ✭ 119 (+310.34%)
Mutual labels:  clustering, classification
Scikit Multilearn
A scikit-learn based module for multi-label et. al. classification
Stars: ✭ 638 (+2100%)
Mutual labels:  clustering, classification
Machine Learning With Python
Practice and tutorial-style notebooks covering wide variety of machine learning techniques
Stars: ✭ 2,197 (+7475.86%)
Mutual labels:  clustering, classification
Practical Machine Learning With Python
Master the essential skills needed to recognize and solve complex real-world problems with Machine Learning and Deep Learning by leveraging the highly popular Python Machine Learning Eco-system.
Stars: ✭ 1,868 (+6341.38%)
Mutual labels:  clustering, classification
Mlj.jl
A Julia machine learning framework
Stars: ✭ 982 (+3286.21%)
Mutual labels:  clustering, classification
Orange3
🍊 📊 💡 Orange: Interactive data analysis
Stars: ✭ 3,152 (+10768.97%)
Mutual labels:  clustering, classification
Satellite imagery analysis
Implementation of different techniques to find insights from the satellite data using Python.
Stars: ✭ 31 (+6.9%)
Mutual labels:  clustering, classification
Stringlifier
Stringlifier is on Opensource ML Library for detecting random strings in raw text. It can be used in sanitising logs, detecting accidentally exposed credentials and as a pre-processing step in unsupervised ML-based analysis of application text data.
Stars: ✭ 85 (+193.1%)
Mutual labels:  clustering, classification
Tribuo
Tribuo - A Java machine learning library
Stars: ✭ 882 (+2941.38%)
Mutual labels:  clustering, classification
Mlr
Machine Learning in R
Stars: ✭ 1,542 (+5217.24%)
Mutual labels:  clustering, classification
Tensorflow Book
Accompanying source code for Machine Learning with TensorFlow. Refer to the book for step-by-step explanations.
Stars: ✭ 4,448 (+15237.93%)
Mutual labels:  clustering, classification
Smile
Statistical Machine Intelligence & Learning Engine
Stars: ✭ 5,412 (+18562.07%)
Mutual labels:  clustering, classification
Machine Learning Projects
This repository consists of all my Machine Learning Projects.
Stars: ✭ 135 (+365.52%)
Mutual labels:  clustering, classification
Uci Ml Api
Simple API for UCI Machine Learning Dataset Repository (search, download, analyze)
Stars: ✭ 190 (+555.17%)
Mutual labels:  clustering, classification

NPM version Build status Test coverage License Downloads

This module implements a Hidden Markov Model featuring methods to obtain the real generation probability and Viterbi approximations as well as methods to initialize and/or reestimate a HMM given a set of generated items with Viterbi re-estimation and linear segmentation.

Dependencies

Implementation itself depends on no additional module.

Usage

This project can be used as a NodeJS module:

var hmm = require( './hmm.js' );
var aModel = new hmm();

Initializing with explicit details

A Hidden Markov Model can be initialized giving the explicit list of states (including final state), symbols, initial probabilities, transition probabilities and emission probabilities.

aModel = new hmm(
	[ '1', '2', '3', 'F' ],
	'F', [ 'a', 'b', 'c' ], {
		'1': 1
	}, {
		'1': {
			'1': 0.2,
			'2': 0.5,
			'3': 0.3
		},
		'2': {
			'1': 0.1,
			'3': 0.9
		},
		'3': {
			'3': 0.4,
			'F': 0.6
		}
	}, {
		'1': {
			'b': 0.3,
			'c': 0.7
		},
		'2': {
			'a': 0.3,
			'b': 0.6,
			'c': 0.1
		},
		'3': {
			'a': 1,
		}
	}
);

Reestimating an existing Hidden Markov Model

If you have an existing HMM and want to reestimate it with some training samples you can do it with reestimate method:

aModel.reestimate( [ [ 'b', 'c', 'b', 'a' ], [ 'b', 'c', 'b', 'b' ], [ 'b', 'c', 'b', 'd' ] ] );

Optionally you can give an array of optimal paths as second parameter. If you don't give that array of paths the method will compute the optimal paths for each one of given items, so be sure that given items could be generated with the model.

Initializing a new Hidden Markov Model given some training samples

To initialize a new Hidden Markov Model without having a previous model you can use initialize method:

aModel.initialize( [ [ 'b', 'c', 'b', 'a' ], [ 'b', 'c', 'b', 'b' ], [ 'b', 'c', 'b', 'd' ] ], 3 );

This method will initialize the model, using linear segmentation to decide which will be the optimal state sequence for each one of the items and after that will reestimate the model.

Getting the probability that a given item is generated by the model

This implementation offers methods to get the real generation probability (using Forward algorithm), the Viterbi approximation and the most probable state sequence.

  • Real probability: Given an array of symbols, generationProbability method will return the probability that those symbols are generated in that order by the model.
  • Viterbi approximation: Given an array of symbols, viterbiApproximation method will return the probability that most probable state sequence generates given symbols in given order.
  • Most probable state sequence: Given an array of symbols, optimalStateSequence will return the most probable state sequence as an array.
var hmm = require( './hmm.js' );
var milk = new hmm();
var something = [ 'white', 'bottle' ];
milk.initialize( [ something ], 2 );
console.log( 'The probability that something white in a bottle is milk is ' +  ( milk.generationProbability( something ) * 100 ) + '%.' );

Printing the model

You can check internal details of the model with print method, which will print details on console:

> milk.print();
A	1	2	F
1	0	1	0
2	0	0	1
F	0	0	0

B	white	bottle
1	1	0
2	0	1

Initial:
1:	1
2:	0
F:	0

Final: F

Development

You'll need to install development dependencies:

npm install --only=dev

Generating documentation

Documentation can be generated running:

npm run-script doc

HTML documentation will be available in doc folder.

Building from Coffeescript source

Although this module is shipped already built you can build it again from CoffeeScript sources running:

npm run-script prepublish

Running tests

You can also run the tests and get coverage information. To run the tests on CoffeeScript source just run:

npm test

If you want to generate additional coverage information run:

npm run-script test-cov

And then you'll find coverage information in coverage folder.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].