3
$\begingroup$

I was checking if it is possible to get per class accuracy from confusion matrix until I found a similar question in SO.

Unfortunately, the answer that to me seems convincing gets negative votes:

Accuracy is a global measure, and there is no such thing as class-wise accuracy.

and the highly upvoted one is followed by hot arguments such as

This calculates not accuracy, but recall

in the comments section. No accepted answer.

I would like to have a YES or NO answer to this question. Is it technically correct (and possible) to get model accuracy per class from confusion matrix?

$\endgroup$
1
  • $\begingroup$ What would "model accuracy per class" mean to you? $\endgroup$
    – Dave
    Commented Sep 8, 2020 at 16:03

1 Answer 1

1
$\begingroup$

No. As described, the upvoted answer in SO calculates the recall, which is the fraction of samples covered for that class, i.e. if there are 5 samples and you correctly identify 3 of them, your recall is 60%. This is achieved by dividing the diagonal entry to the row sum. If you divide the diagonal entry to the column sum, you get precision. None of them are accuracy, and the concept "accuracy per class" doesn't make sense.

$\endgroup$
4
  • $\begingroup$ May I ask: if the confusion matrix gives us only recall and precision, but not accuracy, if I train a model in matlab and it only gives me the confusion matrix, how can I get the overall acuraccy (not per class, the model's accuracy)? $\endgroup$
    – Johanna
    Commented Sep 8, 2020 at 16:26
  • 1
    $\begingroup$ confusion matrix can give you accuracy, it can't give you per class accuracy because there is no such thing. Overall accuracy = sum of diagonals / sum of all entries $\endgroup$
    – gunes
    Commented Sep 8, 2020 at 16:29
  • $\begingroup$ I don't understand why you can't have per class accuracy though? Shouldn't the definition of "class A" accuracy be the same as overall accuracy but for a given class, and therefore the same as recall? $\endgroup$
    – Johanna
    Commented Sep 8, 2020 at 19:06
  • $\begingroup$ But, what is the user of defining another concept of accuracy, which will have the same meaning of recall? $\endgroup$
    – gunes
    Commented Sep 18, 2020 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.