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

Regarding Transition Probabilities #37

Open
Singh-Sonam opened this issue Mar 17, 2022 · 1 comment
Open

Regarding Transition Probabilities #37

Singh-Sonam opened this issue Mar 17, 2022 · 1 comment

Comments

@Singh-Sonam
Copy link

Singh-Sonam commented Mar 17, 2022

Hello

I am using a few covariates for transition, but when I am using the sample code provided to view transition probabilities, it is throwing an error.
For Example : covariates_transition = ['a','b','c','d','e', 'f','g','h','i']

When using print(np.exp(SHMM.model_transition[0].predict_log_proba(np.array([[]])))),
I am getting an error : X has 1 features per sample; expecting 10. How can I get the transition probabilities for the two hidden state model with transition covariates.

Also, how can I get the most likely state for each observation? In hmmlearn ,
remodel = hmm.GaussianHMM(n_components=2).fit(X, lengths)
Z3 = remodel.predict(X) provides the hidden states, how can i get that in this model.

Thank you for all the help.

@ghcsung
Copy link

ghcsung commented Sep 13, 2023

You probably have a covariate (input) associated with the transition probabilities. For the first question I did:

# the number of zeros inside np.array() should be equal to the number of your covariates, I have two inputs.

empty = np.array([[1, 0, 0]]) # 1 for constant

SHMM0.model_transition[0].fit_intercept = False
SHMM0.model_transition[1].fit_intercept = False

print(np.exp(SHMM0.model_transition[0].predict_log_proba(empty)))
print(np.exp(SHMM0.model_transition[1].predict_log_proba(empty)))

This gets the transition probabilities for when your covariates are all 0 (except the constant).

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

2 participants