用于计算语音标记器的准确性的参数 [英] Parameters for calculating accuracy of part of speech tagger

查看:46
本文介绍了用于计算语音标记器的准确性的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是自然语言处理的初学者,我有一个关于计算POS Tagger(tagger使用语料库)的准确性的基本问题:

(不要将下面的"set"一词与set的数学定义混淆.我只是将它用作普通的英语单词来传达一些"group"或"mapping")

有不同的准确性指标,例如精确度/召回率"和混淆矩阵".这两个都需要以下两点作为输入参数:
1. :预测结果集:POS Tagger在输入上运行后,我们将预测输入单词的标签.我了解这个参数;这基本上是标记器使用语料库和一些统计技术生成的.这是我们的预测
2. Actual Result set :这个集合表示每个词的 actual 标签应该是什么.这是 reality .
我的问题是关于第二个参数:应该如何构建"此集合.我是否应该手动构建一个将每个输入单词映射到正确标记的集合?手动是指阅读语料库,然后为每个输入单词找到对应的标签.

所以我的问题基本上是: 如果有一些代码可以计算POS-Tagger的精度,那么针对该精度如何计算?此代码如何知道单词到标签的正确映射?如果它确实知道单词到标签的正确映射,那么为什么不使用这个代码来做标签本身?(我希望读者在这里能理解我的困惑.)

我将给出以下示例:
输入句子:我是男孩.
预测的标记:I_Pronoun am_Noun a_Article boy_Verb.(标记的名称简化,显然标记做错了)

实际标记应为:I_Pronoun am_Verb a_Article boy_Noun
知道标签应该是什么,但是 精度计算器代码如何知道实际的标签应该是什么?我是否应该为每个输入句子手动准备正确标签的映射,然后将其作为参数传递?

请注意,我知道 Precision/Recall 的计算方式.我只是问:我如何告诉它什么是正确的标记集?

解决方案

正如Vsevolod Dyomkin所说,如果要测试程序,则需要具有与实际情况相对应的预先标记数据.您可以手动创建自己的文件,也可以使用可用的文件,例如棕色文集.由于您的标签之一是 scikit-learn ,我假设您正在使用NLTK,这使您可以直接通过 nltk.download()使用它.

虽然我不知道实现的详细信息,但是一旦处理了预测集和实际集,就应该能够使用scikit-learn提供的功能,例如correct tag?. By manually, I mean reading the corpus and then finding what the corresponding tag is for each input word.

So my question basically is: If there's some code that calculates accuracy of a POS-Tagger, what is the accuracy calculated against? How does this code know what is the correct mapping of words to tags? And if it does know the correct mapping of words to tags then why is this code not being used to do the tagging itself? (I hope the reader understands my confusion here).

I'll give this example:
Input sentence : I am a boy.
Predicted Tags : I_Pronoun am_Noun a_Article boy_Verb. (simplified names for tags, and obviously the tagging has been done wrong)

Actual tagging should be : I_Pronoun am_Verb a_Article boy_Noun
I know what the tagging should be, but how does the accuracy calculator code know what the actual tagging should be? Am I supposed manually prepare a mapping of correct tags for each input sentence, and then pass it as a parameter?

Note that I know how the calculation for Precision/Recall works. I'm simply asking: how do I tell it what's the correct tagging set ?

解决方案

As said Vsevolod Dyomkin, if you wish to test your program, you'll need to have pre-labeled data corresponding to reality. You may either create your own manually or use an available one, like the brown corpus. Since one of your tag is scikit-learn, I'll assume you're using NLTK, which enables you to use it directly via nltk.download().

While I'm not aware of implementations details, once you dispose of both the predicted and actual sets, you should be able to use the provided functions of scikit-learn, such as confusion_matrix. For instance,

predicted_tags = ['NOUN', 'VERB']
real_tags = ['NOUN', 'PRONOUN']
confusion_matrix(y_true, y_pred)

will return

array([[1, 0, 0],
       [0, 0, 1],
       [0, 0, 0]])

这篇关于用于计算语音标记器的准确性的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆