Evaluation in AI
Evaluation in AI
1 Precision
Precision measures the percentage of true positive cases out of
all cases where the prediction is positive. It is calculated as TP /
(TP + FP) * 100%.
2 Recall
Recall measures the percentage of true positive cases out of all
actual positive cases. It is calculated as TP / (TP + FN) * 100%.
Precision
Precision is defined as the percentage of true positive cases versus all the cases
where the prediction is true. That is, it takes into account the True Positives and
False Positives.
Going back to the Forest Fire example, in this case, assume that the model always
predicts that there is a forest fire irrespective of the reality. In this case, all the
Positive conditions would be taken into account that is, True Positive (Prediction =
Yes and Reality = Yes) and False Positive (Prediction = Yes and Reality = No). In this
case, the firefighters will check for the fire all the time to see if the alarm was
True or False.
You might recall the story of the boy who falsely cries out that there are wolves
every time and so when they actually arrive, no one comes to his rescue.
Let us consider that a model has 100% precision. This Similarly, here if the Precision is low (which means there are more False alarms
means that whenever the machine says there’s a fire, than the actual ones) then the firefighters would get complacent and might not
there is a fire (True Positive). In the same model, there can go and check every time considering it could be a false alarm.
be a rare exceptional case where there was actual fire but
the system could not detect it. This is the case of a False This makes Precision an important evaluation criteria. If Precision is
Negative condition. But the precision value would not be high, this means the True Positive cases are more, giving lesser False
affected by it because it does not take FN into account. Is alarms.
precision then a good parameter for model performance?
Recall
Another parameter for evaluating the model’s performance is Recall. It can be defined as the fraction of positive cases that are correctly
identified. It majorly takes into account the true reality cases where in Reality there was a fire but the machine either detected it correctly or it
didn’t. That is, it considers True Positives (There was a forest fire in reality and the model predicted a forest fire) and False Negatives (There was
a forest fire and the model didn’t predict it).
Now as we notice, we can see that the Numerator in both Precision and Recall is the same: True Positives. But in the denominator, Precision
counts the False Positives while Recall takes False Negatives into consideration.
F1 Score
Both precision and recall are important metrics, but they often
provide conflicting information. A model might have high
precision but low recall, or vice versa. To address this, we
introduce the F1 score, which combines precision and recall
into a single metric.
The F1 score is calculated as 2 * (Precision * Recall) / (Precision + Recall).
Take a look at the formula and think of when can we get a perfect F1 score?
An ideal situation would be when we have a value of 1 (that is 100%) for both Precision and Recall. In that case,
the F1 score would also be an ideal 1 (100%). It is known as the perfect value for F1 Score. As the values of both
Precision and Recall ranges from 0 to 1, the F1 score also ranges from 0 to 1.
CONFUSION MATRIX ACTIVITY (PART 2)
HOMEWORK QUESTIONS TO TRY:
Find out Accuracy, Precision, Recall and F1 Score for the given problems.
Scenario 1: Scenario 2:
In schools, a lot of times it happens that there is no water to drink. Nowadays, the problem of floods has worsened in some parts
At a few places, cases of water shortage in schools are very of the country. Not only does it damage the whole place but it
common and prominent. Hence, an AI model is designed to predict also forces people to move out of their homes and relocate.
if there is going to be a water shortage in the school in the near To address this issue, an AI model has been created which can
future or not. The confusion matrix for the same is: predict if there is a chance of floods or not. The confusion
matrix for the same is:
Challenge
Find out Accuracy, Precision, Recall and F1 Score for the given problems.
Scenario 3: Scenario 4:
A lot of times people face the problem of sudden downpour. Traffic Jams have become a common part of our lives
People wash clothes and put them out to dry but due to nowadays. Living in an urban area means you have to face
unexpected rain, their work gets wasted. Thus, an AI model has traffic each and every time you get out on the road. Mostly,
been created which predicts if there will be rain or not. The school students opt for buses to go to school. Many times the
confusion matrix for the same is: bus gets late due to such jams and students are not able to
reach their school on time. Thus, an AI model is created to
predict explicitly if there would be a traffic jam on their way
to school or not. The confusion matrix for the same is: