Trusted answers to developer questions

What is precision and recall?

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

Precision

Precision tells us how many, out of all instances that were predicted to belong to class XX, actually belonged to class XX. The precision for class XX is calculated as:

TPTP+FP\frac{TP}{TP+FP}

TPTP = the number of true positives for class XX.

FPFP = the number of false positives for class XX.

Recall

Recall expresses how many instances of class XX were predicted correctly. The recall is calculated as:

TPTP+FN\frac{TP}{TP+FN}

TPTP = the number of true positives for class XX.

FNFN = the number of false negatives for class XX.

Example

Suppose that we have the following confusion matrix:

A confusion matrix
A confusion matrix

Binary classification problems often focus on the positive class; therefore, precision and recall are calculated for the positive class.

Precision

The precision is equal to:

1313+4=0.7647\frac{13}{13+4} = 0.7647

This shows that 76.47%76.47\% of the records that were classified as positive were actually positive.

Recall

The recall is equal to:

1313+3=0.8125\frac{13}{13+3} = 0.8125

This shows that 81.25%81.25\% of the positive instances were classified as positive.

RELATED TAGS

data mining
precision
recall
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?