我使用hmmlearn进行解码。
隐藏状态有六个主题,观察结果为345个字。
start_probability为 enter image description here
transition_probability为 enter image description here
我的代码是:
model = hmm.MultinomialHMM(n_components=n_states)
model.startprob_= start_probability
model.transmat_ = transition_probability
model.emissionprob_ = np.array(emission_probability)
X_seq = np.array([X]).T
logprob, topic = model.decode(X_seq, algorithm="viterbi")
print("Word Sequence:", ", ".join(map(lambda x: observations[x],X)))
print("Ttopic:", ", ".join(map(lambda x: states[x], topic)))
print(logprob)
但是我收到错误消息“ TypeError:输入类型不支持ufunc'log',并且根据转换规则” safe”“
无法将输入安全地强制转换为任何受支持的类型