1

我使用 hmmlearn 进行解码。

隐藏状态有六个主题,观察是 345 个单词。

start_probability 是 在此处输入图像描述

transition_probability 在这里输入图像描述

我的代码是:

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' not supported for the input types, and the input could not be safe to force to any supported types based on the cast rule ''safe''”

4

0 回答 0