我試圖用hmmlearn給出轉換矩陣和先驗emisison矩陣來擬合模型。擬合後,它會在轉換矩陣中給出一些負值。Python - hmmlearn - Negative transmat
轉換矩陣由另一個模型的轉換矩陣恢復。
例子就是我的意思的代碼是:
>>> model
GaussianHMM(algorithm='viterbi', covariance_type='diag',covars_prior=0.01,
covars_weight=1, init_params='stmc', means_prior=0, means_weight=0,
n_components=3, n_iter=100, params='stmc', random_state=123,
startprob_prior=1.0, tol=0.5, transmat_prior=1.0, verbose=True)
>>> model.transmat_
array([[ 9.95946216e-01, 2.06359396e-21, 4.05378401e-03],
[ 2.05184679e-21, 9.98355526e-01, 1.64447392e-03],
[ 3.86689326e-03, 1.96383373e-03, 9.94169273e-01]])
>>> new_model= hmm.GaussianHMM(n_components=model.n_components,
random_state=123,
... init_params="mcs", transmat_prior=model.transmat_)
>>> new_model.fit(train_features)
GaussianHMM(algorithm='viterbi', covariance_type='diag', covars_prior=0.01,
covars_weight=1, init_params='mcs', means_prior=0, means_weight=0,
n_components=3, n_iter=10, params='stmc', random_state=123,
startprob_prior=1.0, tol=0.01,
transmat_prior=array([[ 9.95946e-01, 2.06359e-21, 4.05378e-03],
[ 2.05185e-21, 9.98356e-01, 1.64447e-03],
[ 3.86689e-03, 1.96383e-03, 9.94169e-01]]),
verbose=False)
>>> new_model.transmat_
array([[ 9.98145253e-01, 1.86155258e-03, -7.08313729e-06],
[ 2.16330448e-03, 9.93941859e-01, 3.89483667e-03],
[ -5.44842863e-06, 3.52862069e-03, 9.96478546e-01]])
>>>
代碼所示訓練數據也相同。 如果我沒有在先驗中使用轉換矩陣,例如它的發射是正確的。 我使用的是Anaconda 2.5 64位。 hmmlearn版本是0.2.0
提示? 謝謝