我正在尝试运行隐藏的马尔可夫模型,但是拟合功能无法正常工作。
代码:
import numpy as np
from hmmlearn import hmm
X1 = [[0.5], [1.0], [-1.0], [0.42], [0.24]]
X2 = [[2.4], [4.2], [0.5], [-0.24]]
X = np.concatenate([X1, X2])
lengths = [len(X1), len(X2)]
hmm.GaussianHMM(n_components=3).fit(X, lengths)
我收到此错误消息:
TypeError Traceback (most recent call last)
<ipython-input-16-cdfada1be202> in <module>()
8 lengths = [len(X1), len(X2)]
9
---> 10 hmm.GaussianHMM(n_components=3).fit(X, lengths)
TypeError: fit() takes 2 positional arguments but 3 were given