Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to perform forward algorithm #1

Open
Jk9jk9 opened this issue Sep 9, 2024 · 1 comment
Open

Error when trying to perform forward algorithm #1

Jk9jk9 opened this issue Sep 9, 2024 · 1 comment

Comments

@Jk9jk9
Copy link

Jk9jk9 commented Sep 9, 2024

@Nikhil-Kumar-Patel - this is a really good project! However, I am receiving an error, below, when attempting to perform the forward algorithm. Did you experience this?

/usr/local/lib/python3.10/dist-packages/hmmlearn/hmm.py:352: RuntimeWarning: invalid value encountered in divide
self.means_ = ((means_weight * means_prior + stats['obs'])
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.
WARNING:hmmlearn.base:Some rows of transmat_ have zero sum because no transition from the state was ever observed.

ValueError Traceback (most recent call last)
in <cell line: 14>()
38
39 # Perform the forward algorithm to compute log-likelihoods and forward probabilities
---> 40 log_likelihoods, fwd = model.score_samples(obs[i:i+T])
41
42 # Calculate the number of parameters for the model

4 frames
/usr/local/lib/python3.10/dist-packages/hmmlearn/base.py in _check_sum_1(self, name)
949 s = getattr(self, name).sum(axis=-1)
950 if not np.allclose(s, 1):
--> 951 raise ValueError(
952 f"{name} must sum to 1 (got {s:.4f})"
953 if s.ndim == 0

ValueError: startprob_ must sum to 1 (got nan)

@Jk9jk9
Copy link
Author

Jk9jk9 commented Sep 9, 2024

Note, I found that if it's rerun (and the code below removes another column of obs data, this time the Open data), then it runs fine.

obs = obs[obs.columns[1:5]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant