rebekah tanag
rebekah tanag

Reputation: 29

Multiclass Confusion Matrix

Multiclass Confusion Matrix

I have this multiclass confusion matrix of Asian currencies and this is the first time I've gotten something like this and it's giving me a hard time to interpret it and also identifying the TP, TN, FP, and FN.

I think it's lacking of other values because mostly it only contains the diagonal values and the off diagonal values.

Upvotes: 0

Views: 215

Answers (1)

James
James

Reputation: 36746

Your model is doing an excellent job of categorizing currencies when it is able to distinguish them from the background of the image. Interpreting the True Positive (TP), True Negative (TN), False Positive (FP), and False Negative (FN) in a multiclass classification prediction is not a straight-forward as a binary classification prediction.

The image you have shown gives the fraction of predictions instead of the number, so it is not possible to get the TP, TN, FP, and FN for each class form the image, but it should be relatively easy to get these from the model outputs with the following information:

In multiclass classification, each class is considered as the positive class, and all other classes are considered as the negative class, one class at a time. This is called "one-vs-all" or "one-vs-rest".

If we have 5 classes: A, B, C, D, and background, then for class A we can get the TP, TN, FP, and FN as:

  • TP: number of correct predictions of class A.
  • TN: number of correct predictions for classes B, C, D, and background.
  • FP: number of instances that classes B, C, D and background were incorrectly predicted as class A.
  • FN: Number of times class A was incorrectly predicted as class B, C, D, or background

We then repeat this process for classes B, C, D and background to get the metrics for each class.


Using these numbers to calculate precision, recall, and F1-score, is again more complicated for multiclass classification. You can calculate the precision, recall, and F1-score for each class individually using the standard formulas. However, to get a single measure for the entire model, the per-class metrics are typically averaged across all classes. There are several methods to do this:

  • macro-average: calculate the metric independently for each class and then takes the simple average of the metrics.

  • micro-average: combines the contributions of all classes to compute the average metrics. In other words, sum up the total TP, TN, FP, and FN across all classes to get composite values, and then use those for the precision, recall, and F1-score.

  • weighted-average: calculate metrics for each class, then take the weighted average where the weights are the number of instances in each class.

Upvotes: 0

Related Questions