hmmlearn
Hidden Markov Models in Python with scikit-learn like API
What it is and what it does
hmmlearn provides a suite of algorithms for training and using Hidden Markov Models without labeled data. It wraps the mathematical machinery of HMM inference—forward-backward algorithms, Viterbi decoding, and parameter estimation—behind a scikit-learn-style interface, so if you've used scikit-learn's fit/predict pattern, the API will feel familiar. The package depends on numpy, scikit-learn, and scipy for its numerical and statistical foundations.
Typical use involves fitting an HMM to sequence data (like time series or biological sequences) to learn the underlying state structure, then using that model to decode hidden states or generate predictions. It's built for research and production work on sequence modeling tasks where you don't have ground-truth labels for the states themselves.
Use it for:
- Train HMM models on unlabeled time-series data to discover hidden state patterns in sensor readings or financial data.
- Decode the most likely sequence of hidden states given observed data using Viterbi algorithm.
- Model biological sequences (DNA, protein) where true state labels are unknown but state transitions follow Markovian structure.
- Estimate transition and emission probabilities from sequence data for downstream inference tasks.
- Prototype sequence modeling experiments before moving to more complex approaches.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
hmmlearn implements unsupervised learning and inference algorithms for Hidden Markov Models with a scikit-learn compatible API.
Yes, if you need unsupervised HMM modeling and can accept dormant maintenance. The package is stable, has no known vulnerabilities, and the scikit-learn API integration is well-established. Install friction is moderate (C compiler required) but manageable. Best suited for research, prototyping, or production systems where HMM is the right model and you don't expect active feature development.
Install
hmmlearn on PyPI
pip
pip install hmmlearnuv
uv add hmmlearnpoetry
poetry add hmmlearnInstalling hmmlearn
Before you install
Medium install friction due to C compiler requirement. Package is in dormant maintenance status with last release 652 days ago, though the repository remains active and the codebase is stable.
License in practice
BSD permissive license allows commercial and private use with minimal restrictions.
Quickstart
pip install hmmlearn
import numpy as np
from hmmlearn import hmm
model = hmm.GaussianHMM(n_components=3)
model.fit(X)
hidden_states = model.predict(X)
Requires a C compiler and Python development headers to build from source; prebuilt wheels are available for Python 3.10–3.13 on common platforms.
Verify before relying
- Whether the 652-day gap since last release reflects active maintenance or abandonment risk
- Current state of C compiler compatibility across modern build environments
- Whether scipy is a runtime dependency (listed as runtime but not explicitly documented)
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 3 — numpy, scikit-learn, scipy |
| Maintenance | dormant — 652 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,269,719/month — #4,129 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: hmmlearn-0.3.3-cp310-cp310-macosx_10_9_universal2.whl; hmmlearn-0.3.3-cp310-cp310-macosx_10_9_x86_64.whl; hmmlearn-0.3.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; hmmlearn-0.3.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; hmmlearn-0.3.3-cp310-cp310-win_amd64.whl; hmmlearn-0.3.3-cp311-cp311-macosx_10_9_universal2.whl; hmmlearn-0.3.3-cp311-cp311-macosx_10_9_x86_64.whl; hmmlearn-0.3.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; hmmlearn-0.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; hmmlearn-0.3.3-cp311-cp311-win_amd64.whl; hmmlearn-0.3.3-cp312-cp312-macosx_10_9_universal2.whl; hmmlearn-0.3.3-cp312-cp312-macosx_10_9_x86_64.whl; hmmlearn-0.3.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; hmmlearn-0.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; hmmlearn-0.3.3-cp312-cp312-win_amd64.whl; hmmlearn-0.3.3-cp313-cp313-macosx_10_13_universal2.whl; hmmlearn-0.3.3-cp313-cp313-macosx_10_13_x86_64.whl; hmmlearn-0.3.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; hmmlearn-0.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; hmmlearn-0.3.3-cp313-cp313-win_amd64.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
pyhmmerPyHMMER provides Python bindings to HMMER3, a…
permissive · top 5,000 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
pymc3PyMC3 is a Python package for Bayesian…
permissive · top 15,000 on PyPI
emceeemcee implements affine-invariant ensemble…
permissive · top 5,000 on PyPI
scikit-learn-extraExtends scikit-learn with additional machine…
permissive · top 15,000 on PyPI
skforecastSkforecast is a Python library for time series…
permissive · top 15,000 on PyPI
sklearn-crfsuitesklearn-crfsuite wraps CRFsuite (Conditional…
permissive · top 15,000 on PyPI
soynlpUnsupervised Korean natural language processing…
copyleft · top 15,000 on PyPI
statsmodelsstatsmodels provides statistical models,…
permissive · top 1,000 on PyPI
pgmpypgmpy provides data structures and algorithms…
unclear · top 5,000 on PyPI