Notes on Sensitivity, Specificity, Precision,Recall and F1 score.

Guruprasad
Analytics Vidhya
Published in
3 min readNov 13, 2019

--

It is common to read blood reports that displays results like positive and negative for certain health condition tests.

Say the report states that they have tested negative for Dengue.

What does tested negative even mean ? Does it mean you have dengue or you don’t ?

It’s quite normal to have such confusions if we are not sure what’s the purpose of the test is for. If the medical test is done for checking the presence of dengue and if you tested negative it means you don’t have it.

Most of these tests are classifications.Especially binary classification. Where the output is always boolean i.e It’s either True or False.

Just because the output is True/false it doesn’t mean they are cent percent sure about the accuracy of the classification.Almost all medical tests are not 100% accurate and there is a scope for mistake.What one can expect is to achieve close to 100%. And the output is based on its proximity to being how much true or false.

Ref: https://en.wikipedia.org/wiki/Sensitivity_and_specificity#/media/File:Sensitivity_and_specificity.svg

So when something is classified under binary classification, the output comes under one among the 4 categories.
1.True positive (TP),
2.True negative (TN),
3.False positive (FP),
4.False Negative (FN)

These are qualifiers that define the correctness of the output.
They contain two parts <True/False><Positive/Negative>.

The first part denotes the correctness of the output, while the second part can be the label/value of the classification.

So when we see an output like
Test of presence of Dengue: True
But the patient doesn’t have dengue. Then it categorised as False Positive. i.e The output is falsely stated as positive. Actually the sample has been negative(don’t have dengue) but the classifier stated it as positive(Having dengue).

The 4 aforementioned categories help us to assess the quality of the classification.

Sensitivity :

Sensitivity of a classifier is the ratio between how much were correctly identified as positive to how much were actually positive.

Sensitivity = TP / FN+TP

Where it is used ?
Places where classification of positives are high priority.
Eg: Security checks in airports.

Specificity :

Specificity of a classifier is the ratio between how much were correctly classified as negative to how much was actually negative.

Specificity = TN/FP+TN

Where it is used?
Places where classification of negatives are high priority.
Eg: Diagnosing for a health condition before treatment.

Precision:

How much were correctly classified as positive out of all positives.
Precision = TP/TP+FP

Recall:

Recall and sensitivity are one and the same.
Recall = TP / FN+TP

Where does precision and recall are used ?
The harmonic mean of precision and recall gives a score call
f1 score which is a measure of performance of the model’s classification ability.

F1 score = 2 * (precision * recall)/ (precision + recall)

F1 score is considered a better indicator of the classifier’s performance than the regular accuracy measure.

--

--

Guruprasad
Analytics Vidhya

Math & Data science enthusiast. I write on topics that i have researched and explored for my knowledge gain.