from hmmlearn.hmm import GaussianHMM # creating an instance of Gaussian HMM model model = GaussianHMM(n_components=3, n_features=2) # accessing startprob_ attribute print(model.startprob_)
from sklearn.datasets import make_spd_matrix # generating a random dataset X, _ = make_spd_matrix(n_dim=2, random_state=42) X = np.concatenate([X, 5+X], axis=0) # fitting Gaussian HMM model to the data model = GaussianHMM(n_components=2, covariance_type='full', n_iter=100) model.fit(X) # computing log-likelihood of the data given the model log_likelihood = model.score(X) print('Log-likelihood of the data given the model: {:.2f}'.format(log_likelihood))In both examples, the `hmmlearn` package library is used to create and fit the GaussianHMM model. The `startprob_` attribute is accessed in the first example to show the initial state probabilities of the model. The second example shows how to fit the model to a set of observations, and compute the log-likelihood of the data given the model.