Hello everybody,

I am trying to fit HMM model with two components
*GaussianHMM(n_components = 2)*
to one dimensional vector:

# Code:
from sklearn.hmm import GaussianHMM
import numpy as np
import  matplotlib.pyplot as plt

model = GaussianHMM(n_components = 2)

s1 = np.random.randn(50)
s2 = np.random.randn(50)+5
signal = np.concatenate([s1, s2])

#plt.plot(signal)
#plt.show()

model.fit(signal)

And it gives an error:

..lib/python2.7/site-packages/sklearn/hmm.pyc in _init(self, obs, params)
    754                                               self.n_features))
    755
--> 756         self.n_features = obs[0].shape[1]
    757
    758         if 'm' in params:

IndexError: tuple index out of range

I looked on the examples:
http://scikit-learn.org/stable/auto_examples/applications/plot_hmm_stock_analysis.html#example-applications-plot-hmm-stock-analysis-py

As input is passed : X = np.column_stack([diff, volume]) there.

Is it possible to fit HMM for one-dimensional data?

-- 
Best regards,
Alexandr
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to