Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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)
- Host: GitHub
- URL: https://github.com/howl-anderson/microhmm
- Owner: howl-anderson
- License: mit
- Created: 2018-07-02T13:11:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-15T07:38:33.000Z (almost 5 years ago)
- Last Synced: 2024-11-03T16:51:30.954Z (about 2 months ago)
- Topics: hmm, hmm-viterbi-algorithm, python, viterbi, viterbi-algorithm, viterbi-decoder, viterbi-hmm
- Language: Python
- Homepage:
- Size: 44.9 KB
- Stars: 14
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.en-US.md
- License: LICENSE.txt
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 HMMModelhmm_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)