Code Monkey home page Code Monkey logo

hidden-markov-model's Introduction

Hidden-Markov-Model

A Java implementation of Hidden Markov Model. The implementation contains Brute Force, Forward-backward, Viterbi and Baum-Welch algorithms

Hidden Markov Model is a classifier that is used in different way than the other Machine Learning classifiers. HMM depends on sequences that are shown during sequential time instants. It has many applications such as weather predictions and shines in Speech recognition applications.

After I finish the implementation, I will put the full tutorial of HMM and the javadoc of the API.

Implemented (continuously updating)

  • Json reader
  • Data Validation for an HMM
  • Forward-Backward Algorithm
  • Viterbi Algorithm
  • Baum-Welch Algorithm
  • Javadoc

Json Reader

You can create your model using Json files. In the repository, you will see an example of a model written in a specific expression. I added this feature to help the user to avoid the hard-coding part when entering the model data such as transition and emission matrices.

The Json file is divided to 2 parts, the model info and model data. In model data, you put some information about the model, this enables you when you deal with large amount of models in your projects.

"modelInfo": {
        "name": "HMM1",
		"created_at": "19/12/2015",
		"for": "testing"
	}

You can manually change these data as you wish.

The second part is the model data which is the core of the HMM

"modelData": {
				"states": "R, S, C",
				"initial_prop": "R->0.3, S->0.4, C->0.3",
				"observations": "F, U, D",
				"transition_matrix": "R->R->0.2, R->S->0.1, R->C->0.7, S->R->0.3, S->S->0.4, S->C->0.3, C->R->0.1, C->S->0.4, C->C->0.5",
				"emission_matrix": "R->F->0.4, R->U->0.5, R->D->0.1, S->F->0.4, S->U->0.0, S->D->0.6, C->F->0.4, C->U->0.2, C->D->0.4"
	}

alt tag

How to use

First of all, you should make an instance of the HMM class

HiddenMarkovModel hmm = new HiddenMarkovModel(name, states, observations, initialProbabilities, transitionMatrix, emissionMatrix);

You can create the HMM constructor parameters using 2 ways

  • Put your model data in a json file, then read it like that
JsonParser jp = new JsonParser("G:\\Github Repositories\\Hidden-Markov-Model\\Resources\\test_HMM.json");
String name = DataDecoding.getInstance().getModelName(jp.getName());
Vector<String> states = DataDecoding.getInstance().getStates(jp.getStates());
Vector<String> observations = DataDecoding.getInstance().getObservations(jp.getObservations());
Hashtable<String, Double> initialProbabilities = DataDecoding.getInstance().getInitialProbabilities(jp.getInitialProbabilities());
Hashtable<Pair<String, String>, Double> transitionMatrix = DataDecoding.getInstance().getTransitionMatrix(jp.getTransitionMatrix());
Hashtable<Pair<String, String>, Double> emissionMatrix = DataDecoding.getInstance().getEmissionMatrix(jp.getEmissionMatrix());
  • Hard-code your parameters by setting the elements one by one for each parameter

Tutorials

hidden-markov-model's People

Contributors

ahmedhani 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.