我在使用混淆矩阵时遵循了NLTK的书,但是confusionmatrix看起来很奇怪。在
#empirically exam where tagger is making mistakes
test_tags = [tag for sent in brown.sents(categories='editorial')
for (word, tag) in t2.tag(sent)]
gold_tags = [tag for (word, tag) in brown.tagged_words(categories='editorial')]
print nltk.ConfusionMatrix(gold_tags, test_tags)
有人能解释一下如何使用混淆矩阵吗?在
这是一个真正的文本分类器, 与sklearn和NLTK一起工作
首先,我假设您是从旧的
NLTK
的第05章:https://nltk.googlecode.com/svn/trunk/doc/book/ch05.py得到的代码,特别是您将看到这一节:http://pastebin.com/EC8fFqLU现在,让我们看看
NLTK
中的混淆矩阵,试试:[出来]:
^{pr2}$嵌入在
<>
中的数字是真正数(tp)。从上面的示例中,您可以看到引用中的一个JJ
被错误地标记为来自标记输出的NN
。例如,NN
的一个假阳性,JJ
的一个假阴性。在要访问混淆矩阵(用于计算精度/召回率/fscore),您可以通过以下方式访问假阴性、假阳性和真阳性:
[出来]:
要计算每个标签的Fscore:
[出来]:
我希望上面的内容可以消除
NLTK
中混淆矩阵的用法,下面是上面示例的完整代码:相关问题 更多 >
编程相关推荐