Accuracy is the most widely known performance measurement metric for machine learning models. It is a relatively easy measuring metric, but it is often difficult to understand its credibility based on different scenarios. It is used in classification problems to identify the correct predictions a model makes regarding percentages.
It is the value obtained when we divide the total number of correct predictions the model made by the total number of prediction models made, including the incorrect ones. Acccuracy helps to identify if the applied model is suitable for the available dataset.
Different real-life cases are evaluated through the accuracy metric. Different classifications have different methods to measure the accuracy. Let's discuss the three basic types of classification: binary classification, multiclass classification, and multilabel classification.
In binary classification, the instances are categorized under two classes only based on their attributes and properties, i.e., positive and negative. The goal is to separate the positive and negative cases and then check the accuracy to evaluate how many instances are correctly categorized. We use a simple formula for this calculation that divides the correctly classified cases from the total classified cases.
Where:
TP: positive classes that are correctly predicted as positive.
FN: positive classes that are incorrectly predicted as negative.
TN: negative classes that are correctly predicted as negative.
FP: negative classes that are incorrectly predicted as positive.
Different scenarios require the classification of instances under either a positive class or a negative class to make it clear if the instances have a particular property or not.
In multi-class classification, the instances are categorized under multiple mutually exclusive classes based on their attributes and properties, where each instance can be associated with one class only. For example, if there are three primary colors balls, we can classify them under the red, blue, and yellow class, whereas the yellow ball instance can only be classified under yellow. We use the following formula for this calculation that returns true for the instances whose prediction output matches the true output label.
Where:
Different scenarios require the classification of instances under multiple classes to make it easier to identify the instance based on its properties.
Note: Learn more about implementation through an image classification example.
In multi-label classification, the instances are categorized under multiple mutually non-exclusive classes based on their properties, where each instance can be associated with multiple classes. It has a more balanced metric because there are more relaxed class categorizations available in it. We use the following formula for this calculation that returns and divides the instances whose prediction output matches the true output label out by all the instances for which an output label exists.
Where:
n: total number of samples used for calculating accuracy.
ti ∩ pi: samples for which the true and predicted output label are the same.
ti ∪ pi: All the samples with a true or a predicted output label.
Different scenarios require classifying instances under multiple labels to make it easier to find instances based on their attributes.
Accuracy works best on balanced datasets and possibly gives a faulty result on an imbalanced dataset. For example, if the ratio of a fault occurrence and no-fault occurrence is 1: 99, then the accuracy will be 99%, ignoring that 1%. In this case, accuracy is a false indicator of model health.
Match the classification types to the real-life scenarios they are used in.
Multi-class classification
The yellow instance comes under primary colors and bright colors labels.
Multi-label classification
Check the patient’s pulse to classify it as dead or alive.
Binary classification
720 THz frequency instance falls under the violet label among the rainbow colors.