Confuses X in GaussianHMM.fit ([X])

With this code:

X = numpy.array(range(0,5)) model = GaussianHMM(n_components=3,covariance_type='full', n_iter=1000) model.fit([X]) 

I get

 tuple index out of range self.n_features = obs[0].shape[1] 

So what should you pass .fit () exactly? Hidden states and outliers in a tuple? If so, in what order? The documentation is less useful.

I noticed that he likes to go through tuples, as this does not give an error:

 X = numpy.column_stack([range(0,5),range(0,5)]) model = GaussianHMM(n_components=3,covariance_type='full', n_iter=1000) model.fit([X]) 

Edit:

Let me clarify a bit, the documentation indicates that the routine of the array should be:

List of observation sequences similar to an array (form (n_i, n_features)).

This almost means that you pass a tuple for each sample, which indicates in a binary way which observations are present. However, their example indicates otherwise:

 # pack diff and volume for training X = np.column_stack([diff, volume]) 

therefore confusion

+6
source share
2 answers

It would seem that the Gaussian HMM function is intended for problems with multidimensional emission of only HMM, therefore, it is required to have> 1 emission vectors. When โ€œn_featuresโ€ is mentioned in the documentation, they are not among the methods of emission extraction, but rather the number of orthogonal emission vectors.

Therefore, โ€œsignsโ€ (orthogonal emission vectors) should not be confused with โ€œsymbolsโ€, which sklearn believes (which are likely to be shared with the large hmm community for everyone I know), refer to what actual unique values the system can radiate.

For one-dimensional emission vector problems, use MultinomialHMM.

Hope this is clarified by someone who wants to use this material without becoming the main authority in the world at HMM :)

+1
source

I understand this is an old thread, but the problem in the sample code still exists. I believe the example is now in this link and still giving the same error:

 tuple index out of range self.n_features = obs[0].shape[1] 

Offensive line of code: model = GaussianHMM(n_components=5, covariance_type="diag", n_iter=1000).fit(X)

What should be: model = GaussianHMM(n_components=5, covariance_type="diag", n_iter=1000).fit([X])

0
source

Source: https://habr.com/ru/post/988948/


All Articles