probml / probml/dynamax

Support for HMMs with num_states=1

Open
#380 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1k
Forks
114
Avg merge
19h 14m
Merged PRs (30d)
1

Description

I am trying to fit various HMM classes (LinearRegressionHMM, or GaussianHMM) to my data but it does not let me pass num_states=1. For num_states > 2, everything works as expected. I wanted to know whether no support for num_states=1 is the intended behavior.

It's easy enough to write code for simple linear regression outside dynamax, however, it still makes the comparison with num_states>2 cases error-prone (as one might be using different constants in log-likelihood calculations, etc.).

If it helps, the error occurs while trying to initialize the Dirichlet distribution.

File "/Users/us/project/fitting.py", line 20, in fitEM
    params, props = hmm.initialize(key)
  File "/Users/us/dynaenv/lib/python3.10/site-packages/dynamax/hidden_markov_model/models/gaussian_hmm.py", line 649, in initialize
    params["initial"], props["initial"] = self.initial_component.initialize(key1, method=method, initial_probs=initial_probs)
  File "/Users/us/dynaenv/lib/python3.10/site-packages/dynamax/hidden_markov_model/models/initial.py", line 45, in initialize
    initial_probs = tfd.Dirichlet(self.initial_probs_concentration).sample(seed=this_key)
...
ValueError: Argument `concentration` must have `event_size` at least 2.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in hidden_markov_model/models/initial.py at the Dirichlet initialization called from hidden_markov_model/models/gaussian_hmm.py:649. Trace how initialization handles num_states=1, then verify that LinearRegressionHMM and GaussianHMM can initialize and fit with one state without the reported concentration error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.