我目前正在使用 NLTK 的朴素贝叶斯分类器,但我也想尝试 Max Ent 分类器。从文档看来,它应该采用与朴素贝叶斯相同的功能集格式,但由于某种原因,当我尝试它时出现此错误:
File "/usr/lib/python2.7/site-packages/nltk/classify/maxent.py", line 323, in train
gaussian_prior_sigma, **cutoffs)
File "/usr/lib/python2.7/site-packages/nltk/classify/maxent.py", line 1453, in train_maxent_classifier_with_scipy
model.fit(algorithm=algorithm)
File "/usr/lib64/python2.7/site-packages/scipy/maxentropy/maxentropy.py", line 1026, in fit
return model.fit(self, self.K, algorithm)
File "/usr/lib64/python2.7/site-packages/scipy/maxentropy/maxentropy.py", line 226, in fit
callback=callback)
File "/usr/lib64/python2.7/site-packages/scipy/optimize/optimize.py", line 636, in fmin_cg
gfk = myfprime(x0)
File "/usr/lib64/python2.7/site-packages/scipy/optimize/optimize.py", line 176, in function_wrapper
return function(x, *args)
File "/usr/lib64/python2.7/site-packages/scipy/maxentropy/maxentropy.py", line 420, in grad
G = self.expectations() - self.K
ValueError: shape mismatch: objects cannot be broadcast to a single shape
我不确定这意味着什么,但我使用的输入与我运行朴素贝叶斯时使用的输入完全相同,并且有效。(训练数据,表示为对列表,其中第一个成员是特征集,并且第二个是分类标签。)有什么想法吗?
谢谢!