我在这里编写代码:
print ('pos precision:', nltk.metrics.precision(refsets['pos'],
testsets['pos']))
print ('pos recall:', nltk.metrics.recall(refsets['pos'],
testsets['pos']))
和输出如下:
line 35, in evaluate_classifier
print ('pos precision:', nltk.metrics.precision(refsets['pos'],
testsets['pos']))
AttributeError: module 'nltk.translate.metrics' has no attribute
'precision'
我该如何解决这个错误?
答案 0 :(得分:0)
没什么大不了的,只是没有调用正确的方法。
尝试:nltk.metrics.scores.precision(reference, test)
http://www.nltk.org/api/nltk.metrics.html
ctrl + f表示“精确”会让你获得文档
更正后的代码:
print('pos precision:', nltk.metrics.scores.precision(refsets['pos'],testsets['pos']))
print('pos recall:', nltk.metrics.scores.recall(refsets['pos'],testsets['pos']))