precision and recall in fastText?

3.4k views Asked by At

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
2

There are 2 answers

0
WINGLEUNG CHOI On

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

0
Karthikeyan On

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