Skip to main content

中文版本的 README

FastHMM

A python package for HMM (Hidden Markov Model) model with fast train and decoding implementation

Python version

test by using Python3

Install

pip

pip install FastHMM

source

pip install git+https://github.com/312shan/FastHMM.git

Usage

from FastHMM.hmm import HMMModel

# test model training and predict
hmm_model = HMMModel()
hmm_model.train_one_line([("我", "r"), ("爱", "v"), ("北京", "ns"), ("天安门", "ns")])
hmm_model.train_one_line([("你", "r"), ("去", "v"), ("深圳", "ns")])
result = hmm_model.predict(["俺", "爱", "广州"])
print(result)

# test save and load model
hmm_model.save_model()
hmm_model = HMMModel().load_model()
result = hmm_model.predict(["我们", "爱", "深圳"])
print(result)

Output:

[('俺', 'r'), ('爱', 'v'), ('广州', 'ns')]
[('我们', 'r'), ('爱', 'v'), ('深圳', 'ns')]

Performance:

test on dataset 人民日报

python .test/test_postagging.py

Output:

train size 18484 ,test_size 1000
finish training
eval result: 
predict 57929 tags, 54228 correct,  accuracy 0.9361114467710473
runtime : 370.1029086 seconds

Most of time the consuming is on the decoding stage, I tried many ways to implement viterbi algorithm, The implementation I currently use is the fastest If you have suggestions for improving this decoding algorithm, please let me know, thank you very much.

Reference

MicroHMM
Hidden Markov model
Viterbi algorithm

Metadata

Release files for FastHMM 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for FastHMM 0.1.2
File Size Uploaded
FastHMM-0.1.2.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for FastHMM 0.1.2
File Interpreter ABI Platform
FastHMM-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / FastHMM-0.1.2.tar.gz

Download URL FastHMM-0.1.2.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
157856e9e7505a2a9f7e1d1ea59cb6ed8696be25d7160e3a8abf9cdc512c0353
BLAKE2b-256 checksum
How to use checksums
fc7ba179d1aed2d46c24a727909ad3f05651d2732de5487986979fdcce5ee1ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

Release files / FastHMM-0.1.2-py3-none-any.whl

Download URL FastHMM-0.1.2-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
360c01d063f0340b7cb56df7f0cc3a91a17017913c445a6207d8d670ae15b361
BLAKE2b-256 checksum
How to use checksums
972cdcb2b902cb4e3856416aa2a841a7ba7e01148edd9978b9447b40c2dacb5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page