precision and recall in fastText?

故事扮演 提交于 2019-12-06 06:39:20

问题


I implement the fastText for text classification, link https://github.com/facebookresearch/fastText/blob/master/tutorials/supervised-learning.md I was wondering what's the precision@1, or P@5 means? I did a binary classification, but I tested different number, I don't understand results:

haos-mbp:fastText hao$ ./fasttext test trainmodel.bin train.valid 2
N   312
P@2 0.5
R@2 1
Number of examples: 312
haos-mbp:fastText hao$ ./fasttext test trainmodel.bin train.valid 1
N   312
P@1 0.712
R@1 0.712
Number of examples: 312
haos-mbp:fastText hao$ ./fasttext test trainmodel.bin train.valid 3
N   312
P@3 0.333
R@3 1
Number of examples: 312

回答1:


Precision is the ratio of number of relevant results and total number of results retrieved by the program. Assume a document search engine, retrieved 100 docs out of which 90 are relevant to the query, then the precision is 90 / 100 (0.9). Since we have calculated the precision with 100 results, this is P@100.

And Recall is the ratio of relevant results retrieved by the algorithm and total number of the all relevant results. With the same example above, if the total number of relevant documents is 110, then the recall is 90 / 110.

In a nutshell, recall helps to evaluate an information retrieval program on how complete it is, in terms of fetching relevant results; and precision helps to evaluate on how accurate the results are.

Please check this for binary classification in fasttext also, https://github.com/facebookresearch/fastText/issues/93




回答2:


Precision is a ratio of number of correctly predicted labels over number of labels predicted by the model

Recall is a ratio of number of correctly predicted labels over number of actual labels from validation dataset.

For examples: Actual labels for a input in validation dataset: A, B, C, F, G

Predicted labels for the input from the model: A, B, C, D

Correctly predicted labels: A, B, C

Precision: 3 / 4 = 0.75

Recall: 3 / 5 = 0.6



来源:https://stackoverflow.com/questions/46129903/precision-and-recall-in-fasttext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!