Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
199 views
in Technique[技术] by (71.8m points)

scikit learn - Confusion Matrix Classification Report - Keras

I was running a code picked from git to understand how it works. Here is my accuracy/loss that I can understand , but I need help to articulate this confusion matrix and the report. Need you help in this.

loss: 0.0553 - acc: 0.9826 - val_loss: 0.0492 - val_acc: 0.9825

Confusion Matrix

[[22 10 11  1 15  8  8  8 26 15 14 25  3 33 20]
 [ 9  3  7  3 13  6  2  5  8  6  8  3  0 16 17]
 [11  6  8  0  8  5  1  4  7  9  8  6  1 20 12]
 [ 3  0  2  0  0  2  0  0  2  2  2  2  0  4  2]
 [25  8  3  4 18 10  7  8 11 11 10  7  2 23 11]
 [12  3  4  2  7 13 10  3 15  6  7  3  3 19  9]
 [ 7  5  4  3  5  6  8  4  7  4  7  8  2 19 12]
 [ 6  6  3  0  9  7  7  4  6  8  7  6  2 23  6]
 [18  8  7  2 16  8 10 17 20 25 22 12  3 28 14]
 [17  9 10  3 15  6  7  8 16 15 15 21  0 33 13]
 [15  5  7  3 13 15  8  9 12  8 10 14  2 32 14]
 [17  8  7  0  7  7  6  8 12 15  8  9  3 32 11]
 [ 2  2  1  0  1  1  5  0  4  4  4  3  0  1  1]
 [38 22 26  2 20 15 19 13 41 34 24 20  7 50 23]
 [14  9  9  0 11 11  9  7 18 20 16 14  1 22 14]]

below is the classification report.

Classification Report
          precision    recall  f1-score   support

     A       0.10      0.10      0.10       219
     B       0.03      0.03      0.03       106
     C       0.07      0.08      0.07       106
     D       0.00      0.00      0.00        21
     E       0.11      0.11      0.11       158
     F       0.11      0.11      0.11       116
     G       0.07      0.08      0.08       101
     H       0.04      0.04      0.04       100
     I       0.10      0.10      0.10       210
     J       0.08      0.08      0.08       188
     K       0.06      0.06      0.06       167
     L       0.06      0.06      0.06       150
     M       0.00      0.00      0.00        29
     N       0.14      0.14      0.14       354
     O       0.08      0.08      0.08       175


   micro avg       0.09      0.09      0.09      2200
   macro avg       0.07      0.07      0.07      2200
weighted avg       0.09      0.09      0.09      2200

Please help me to understand the classification report. I read theory for confusion matrix but unable to articulate this keras output. Also, what is micro avg,mcro avg etc .Need help to understand . Is the above accuracy seems fine. Please pardon me, I am very new to this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I guess you are struggeling with micro avg the most. Precision, recall and f1 are very basic and you will find a clean explanation here:

For Micro Avg you can find a good example here: But basically it is just an different way to calculate the average.

Micro- and macro-averages (for whatever metric) will compute slightly different things, and thus their interpretation differs. A macro-average will compute the metric independently for each class and then take the average (hence treating all classes equally), whereas a micro-average will aggregate the contributions of all classes to compute the average metric. In a multi-class classification setup, micro-average is preferable if you suspect there might be class imbalance (i.e you may have many more examples of one class than of other classes).

Cited from here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...