Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.26 KB

README.en-US.md

File metadata and controls

51 lines (38 loc) · 1.26 KB

MicroHMM

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

Python version

Only test by using Python3

Install

pip

pip install MicroHMM

source

pip install git+https://github.com/howl-anderson/MicroHMM.git

Usage

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:

[('你', '人称'), ('是', '动词'), ('中国人', '名词')]

Online demo

Binder

Used by

Reference

Speech and Language Processing > Hidden Markov Models