rba
rba

Reputation: 87

Calculating mean per class accuracy in Multi class classification Problem?

I am using multi class classification problem and solved using XGBoost. Number of unique classes are 7.

I Got Classification report with each class Precision, Recall and F1 score.

I did not have any coding clue to try on this in Python.

I need Mean Per Class Accuracy of each class. Is there any mathematical formula to calculate Per class accuracy.

Update:

Test data per class samples:
 Class   # samples
   0      13
   1      16
   2       9

SVM predictions per class samples:
  Class   # samples
   0        13
   1        15
   2        10

SVM Classification Report is:
svm               precision    recall  f1-score   support

           0       1.00      1.00      1.00        13
           1       1.00      0.94      0.97        16
           2       0.90      1.00      0.95         9

   micro avg       0.97      0.97      0.97        38
   macro avg       0.97      0.98      0.97        38
weighted avg       0.98      0.97      0.97        38

Can you please suggest me based on this?

Upvotes: 2

Views: 3506

Answers (1)

qscgy
qscgy

Reputation: 311

Per-class recall = (members of class identified correctly)/(number of members of class)

Simply multiply each per-class recall value by the number of samples that are actually in the class to get the number of each class classified correctly, add these up to get the total number of correct predictions, and then divide by the total number of samples to get the mean per-class accuracy.

Upvotes: 3

Related Questions