-
Notifications
You must be signed in to change notification settings - Fork 119
Documentation on hidden_state_probabilities #1506
Comments
Many properties that are internally computed by the BHMM package come in a time-lagged form that was produced by
So that's what you get for the different arrays in |
Thank you! There doesn't seem to be documentation on the BHMM package or am I missing it? I appreciate your suggestion but I'm not sure how to get the HMM output probabilities. I don't see an property where the same information is so that I can create a similar plot to tutorial 7 (in order to check my sampling as tutorial 8 suggests). |
Hi there! There is no hosted documentation of the BHMM package right now. What you can do though is look at the HMM implementation of deeptime It contains the same algorithms as the BHMM package but is more performant and stable. The |
This is a toy example (Prinz potential). Here it is two trajectories with a lagtime of 3, yielding 6 state probability sequences (one per trajectory per lagtime shift): import numpy as np
import matplotlib.pyplot as plt
from deeptime.data import prinz_potential
from deeptime.clustering import BoxDiscretization
from deeptime.clustering import ClusterModel
from deeptime.markov.msm import MaximumLikelihoodMSM
import deeptime.markov.hmm as hmm
system = prinz_potential()
trajs = system.trajectory(np.zeros((2, 1)), length=20000)
clustering = BoxDiscretization(dim=1, n_boxes=1000).fit_fetch(np.concatenate(trajs))
dtrajs = [clustering.transform(trajs[i]) for i in range(len(trajs))]
hmm_init = hmm.init.discrete.metastable_from_data(dtrajs=dtrajs, n_hidden_states=4, lagtime=3)
mlhmm = hmm.MaximumLikelihoodHMM(hmm_init, lagtime=3).fit_fetch(dtrajs)
print(f"Got {len(mlhmm.state_probabilities)} state probability sequences "
f"from {len(trajs)} trajectories and a lagtime of {mlhmm.lagtime}.")
f, axes = plt.subplots(nrows=3, ncols=2, figsize=(12, 8))
for ix, ax in enumerate(axes.flatten()):
for hidden_state in range(4):
xs = np.arange(50)*mlhmm.lagtime
ax.plot(xs, mlhmm.state_probabilities[ix][:, hidden_state][:50]) To run it it should suffice to install deeptime ( |
If anything we should upload a documentation for bhmm at some point or at least reference to the deeptime implementation given that is largely unmaintained at this point. Closing this issue. |
Hello,
I'd like to plot the probability of being in each hidden state as a function of time. In tutorial 7, the hidden_state_probabilities property is used. I can't find any documentation about the property outside of that tutorial. My main question is about the 1st index. I have 13 trajectories that I used for the features but the first index is of size 130. The second and third index seem to be [frame, hmm state]. Since some of my trajectories are of different length I can see that the hidden_state_probabilities[0:9] are all the same trajectory, the hidden_state_probabilities[10-19] are the same, etc. What is the difference between the hidden_state_probabilities[0] and hidden_state_probabilities[1] then?
The text was updated successfully, but these errors were encountered: