Skip to content

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

License

Notifications You must be signed in to change notification settings

howl-anderson/MicroHMM

Repository files navigation

MicroHMM

一个微型的基于 Python 的 HMM (隐马尔可夫模型) 包.

Python 版本

只在 Python 3 下进行过测试

安装

pip

pip install MicroHMM

source

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

使用

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)

输出:

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

在线演示

Binder

Roadmap

  • [TODO] 使用预先 math.log 的处理方式,加速运行速度
  • [TODO] 解决 math.log 在偶然情况写下会出现的 math domain error

Used by

Reference

Speech and Language Processing > Hidden Markov Models

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published