Professional Documents
Culture Documents
Assignment 2 Part 2
Assignment 2 Part 2
Assignment
Supervised By
Prepared By
Saif Allah Mohamed Bakry
What are the performance metrics for Machine learning
Models?
o There are Two types of performance metrics
Confusion Matrix
Accuracy
Precision
Recall
Specificity
F1 Score
2|Page
Accuracy
It is the most frequently used performance metric for classification algorithms. It can
be defined as the proportion of correct predictions made to total predictions made.
We can easily calculate it using the confusion matrix and the following formula.
𝐓𝐏+𝐓𝐍
𝐀𝐜𝐜𝐮𝐫𝐚𝐜𝐲 =
𝐓𝐏+𝐅𝐏+𝐅𝐍+𝐓𝐍
Confusion matrix
It is the most basic way to evaluate the performance of a classification problem with
two or more types of classes as output. A confusion matrix is simply a table with
two dimensions: "Actual" and "Predicted," as well as "True Positives (TP)", "True
Negatives (TN)", "False Positives (FP)", and "False Negatives (FN)", as shown
below
Figure 1
Precision
In document retrieval, precision is defined as the number of correct documents returned by
our ML model. We can easily calculate it using the confusion matrix and the following
formula
𝑇𝑃
𝑷𝒓𝒆𝒄𝒊𝒔𝒊𝒐𝒏 =
𝑇𝑃 + 𝐹𝑃
3|Page
Recall
The number of positives returned by our ML model can be defined as recall. We can easily
calculate it using the confusion matrix and the following formula
𝑻𝑷
𝑹𝒆𝒄𝒂𝒍𝒍 =
𝑻𝑷 + 𝑭𝑵
Specificity
Specificity, as opposed to recall, can be defined as the number of negatives returned by our
ML model. We can easily calculate it using the confusion matrix and the formula below
𝑻𝑵
𝐒𝐩𝐞𝐜𝐢𝐟𝐢𝐜𝐢𝐭𝐲 =
𝑻𝑵 + 𝑭𝑷
F1 Score
The harmonic mean of precision and recall will be calculated using this score.The weighted
average of precision and recall is used to compute the F1 score. F1's best value is 1 and its
worst value is 0. The following formula can be used to calculate F1 score through the
following equation
𝟐 ∗ (𝐩𝐫𝐞𝐜𝐢𝐬𝐢𝐨𝐧 ∗ 𝐫𝐞𝐜𝐚𝐥𝐥)
𝑭𝟏 =
(𝐩𝐫𝐞𝐜𝐢𝐬𝐢𝐨𝐧 + 𝐫𝐞𝐜𝐚𝐥𝐥)
4|Page
o Performance Metrics for Regression
R Squared (R2)
R Squared (R2)
The R Squared metric is frequently used for explanatory purposes, and it indicates the
goodness or fit of a set of predicted output values to the actual output values. The following
equation will assist us in comprehending it.
𝟏 ∑𝒏𝒊 = 𝟏(𝒀𝒊 − 𝒀𝒊^)𝟐
𝟐
𝑹 =𝟏− 𝒏
𝟏
𝒏 ∑𝒏𝒊 = 𝟏(𝒀𝒊 − 𝒀𝒊)𝟐¯
5|Page