What is precision and recall?

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.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved