Metadata-Version: 2.1
Name: hmm-py
Version: 0.0.1
Summary: A python module to implement Hidden Markov hidden_markov for financial times series.
Home-page: https://github.com/Cstolborg/hmmpy
Author: Cstolborg
Author-email: christianstolborg@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: numpy (>=1.20.1)
Requires-Dist: scikit-learn (>=0.24.0)
Requires-Dist: scipy (>=1.5.4)
Requires-Dist: pandas (>=1.2.0)
Requires-Dist: cvxpy (==1.1.10)
Requires-Dist: tqdm
Requires-Dist: cython
Provides-Extra: docs
Requires-Dist: Sphinx ; extra == 'docs'
Requires-Dist: sphinx-gallery ; extra == 'docs'

HMMpy
======
[![Build Status](https://travis-ci.com/Cstolborg/HMMpy.svg?branch=main)](https://travis-ci.com/Cstolborg/HMMpy)
[![Documentation Status](https://readthedocs.org/projects/hmmpy/badge/?version=latest)](https://hmmpy.readthedocs.io/en/latest/?badge=latest)

**The HMMpy documentation is at [https://hmmpy.readthedocs.io/en/latest/](https://hmmpy.readthedocs.io/en/latest/).**

- [Installation](#installation)
- [Getting started](#getting-started)

HMMpy is a Python-embedded modeling language for hidden markov models. It currently supports training of 2-state models using either maximum-likelihood or jump estimation, and uses and API that is very similar to scikit-learn.

HMMpy began as a University project at Copenhagen Business School, where it was used for financial times series forecasting in an asset allocation project. 


## Installation
HMMpy is available on PyPI, and can be installed with (only for windows)
```
pip install hmm-py
```

HMMpy has the following dependencies:

- Python >= 3.8
- Cython >= 0.29
- NumPy >= 1.20.1
- Pandas >= 1.2.0
- SciPy >= 1.5.4
- tqdm


## Getting started
The following code samples some data, and then trains a hidden markov model using the JumpHMM class:

```python3
from hmmpy.jump import JumpHMM
from hmmpy.sampler import SampleHMM

# Instantiate the HMM model
hmm = JumpHMM(random_state=42)

# Instantiate the sampler with user defined HMM model parameters
hmm_params = {'mu': [0.1, -0.05],
              'std': [0.1, 0.2],
              'tpm': [[1-0.0021, 0.0021],
                      [0.0120, 1-0.0120]]
             }
sampler = SampleHMM(hmm_params=hmm_params, random_state=42)

# Simulate data
observations, state_sequence = sampler.sample(n_samples=2000, n_sequences=1)  # Outputs 2000 observations and the underlying states

# Fit the model
hmm.fit(observations)

# Inspect model parameters
print(hmm.mu)
print(hmm.std)
print(hmm.tpm)
```



