IOHMM icon indicating copy to clipboard operation
IOHMM copied to clipboard

Regarding Transition Probabilities

Open Singh-Sonam opened this issue 4 years ago • 1 comments

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.

Singh-Sonam avatar Mar 17 '22 18:03 Singh-Sonam

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).

ghcsung avatar Sep 13 '23 20:09 ghcsung