Hello Everyone,
I've used the Scikit-Learn Gaussian HMM module to learn the parameters and
state transitions in a time series data set. I now wish to use the learned
parameters (the transition probability matrix, mean and initial state
probabilities) to initialize my HMM model and test it on new data.
Unfortunately, I get an error message whenever I try to initialize the HMM
transition probability matrix. Here is a portion of my code (my model has 3
states):
means = [[1.30422222e+09,6.7],[1.30568756e+09,193],[1.30441054e+09,424]]
transmat = np.array([[0.9964, 0.002, 0.0016], [0.0087, 0.9913, 0], [.0097,
.0015, .9888]])
model = GaussianHMM(n_states,"diag", startprob, transmat)
model.means_ = means
model.fit([data],10, init_params = 'c')
and here is the error message I receive:
C:\Python27\lib\site-packages\sklearn\utils\extmath.py:231: RuntimeWarning:
invalid value encountered in subtract
out = np.log(np.sum(np.exp(arr - vmax), axis=0))
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\xy\Research Scripts\Trainv3.py", line
56, in <module>
model.fit([data],10, init_params = 'c')
File "C:\Python27\lib\site-packages\sklearn\hmm.py", line 440, in fit
self._do_mstep(stats, params)
File "C:\Python27\lib\site-packages\sklearn\hmm.py", line 760, in
_do_mstep
super(GaussianHMM, self)._do_mstep(stats, params)
File "C:\Python27\lib\site-packages\sklearn\hmm.py", line 566, in
_do_mstep
axis=1)
File "C:\Python27\lib\site-packages\sklearn\hmm.py", line 479, in
_set_transmat
raise ValueError('Rows of transmat must sum to 1.0')
ValueError: Rows of transmat must sum to 1.0
>>>
I have confirmed that each row of the transition probability matrix sums to
one, and have replaced my transition probability matrix with 3x3 identity
matrix but I still get the same error. I will appreciate any help I can get
in figuring out the problem. Thanks
Abiodun
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general