Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/howl-anderson/microhmm

一个微型的基于 Python 的 HMM (隐马尔可夫模型) 包 | A micro python package for HMM (Hidden Markov Model)
https://github.com/howl-anderson/microhmm

hmm hmm-viterbi-algorithm python viterbi viterbi-algorithm viterbi-decoder viterbi-hmm

Last synced: about 1 month ago
JSON representation

一个微型的基于 Python 的 HMM (隐马尔可夫模型) 包 | A micro python package for HMM (Hidden Markov Model)

Awesome Lists containing this project

README

        

[中文版本的 README](README.md)
------------------------------

# MicroHMM

A micro python package for HMM (Hidden Markov Model).

## Python version
Only test by using Python3

## Install
### pip
```bash
pip install MicroHMM
```

### source
```bash
pip install git+https://github.com/howl-anderson/MicroHMM.git
```

## Usage
```python
from MicroHMM.hmm import HMMModel

hmm_model = HMMModel()

# train model line by line
# input format: list of (observation, hidden_state) pair
hmm_model.train_one_line([("我", "人称"), ("是", "动词"), ("中国人", "名词")])
hmm_model.train_one_line([("你", "人称"), ("去", "动词"), ("上海", "名词")])

# predict by line
# input format: list of observation
result = hmm_model.predict(["你", "是", "中国人"])
print(result)
```

Output:
```python
[('你', '人称'), ('是', '动词'), ('中国人', '名词')]
```

## Online demo
[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/howl-anderson/MicroHMM/master?filepath=.notebooks%2Fdemo.ipynb)

## Used by
* [MicroTokenizer: 一个微型中文分词引擎 | A micro tokenizer for Chinese](https://github.com/howl-anderson/MicroTokenizer)

## Reference
[Speech and Language Processing > Hidden Markov Models](https://web.stanford.edu/~jurafsky/slp3/9.pdf)