/
overall_test.py
1090 lines (1090 loc) · 85.1 KB
/
overall_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
>>> from pycm import *
>>> import os
>>> import json
>>> y_actu = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2]
>>> y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2]
>>> cm = ConfusionMatrix(y_actu, y_pred)
>>> cm
pycm.ConfusionMatrix(classes: [0, 1, 2])
>>> len(cm)
3
>>> print(cm)
Predict 0 1 2
Actual
0 3 0 0
<BLANKLINE>
1 0 1 2
<BLANKLINE>
2 2 1 3
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
Overall Statistics :
<BLANKLINE>
95% CI (0.30439,0.86228)
ACC Macro 0.72222
AUNP 0.66667
AUNU 0.69444
Bennett S 0.375
CBA 0.47778
Chi-Squared 6.6
Chi-Squared DF 4
Conditional Entropy 0.95915
Cramer V 0.5244
Cross Entropy 1.59352
F1 Macro 0.56515
F1 Micro 0.58333
Gwet AC1 0.38931
Hamming Loss 0.41667
Joint Entropy 2.45915
KL Divergence 0.09352
Kappa 0.35484
Kappa 95% CI (-0.07708,0.78675)
Kappa No Prevalence 0.16667
Kappa Standard Error 0.22036
Kappa Unbiased 0.34426
Lambda A 0.16667
Lambda B 0.42857
Mutual Information 0.52421
NIR 0.5
Overall ACC 0.58333
Overall CEN 0.46381
Overall J (1.225,0.40833)
Overall MCC 0.36667
Overall MCEN 0.51894
Overall RACC 0.35417
Overall RACCU 0.36458
P-Value 0.38721
PPV Macro 0.56667
PPV Micro 0.58333
Pearson C 0.59568
Phi-Squared 0.55
RCI 0.34947
RR 4.0
Reference Entropy 1.5
Response Entropy 1.48336
SOA1(Landis & Koch) Fair
SOA2(Fleiss) Poor
SOA3(Altman) Fair
SOA4(Cicchetti) Poor
SOA5(Cramer) Relatively Strong
SOA6(Matthews) Weak
Scott PI 0.34426
Standard Error 0.14232
TPR Macro 0.61111
TPR Micro 0.58333
Zero-one Loss 5
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes 0 1 2
ACC(Accuracy) 0.83333 0.75 0.58333
AGM(Adjusted geometric mean) 0.83729 0.692 0.60712
AM(Difference between automatic and manual classification) 2 -1 -1
AUC(Area under the roc curve) 0.88889 0.61111 0.58333
AUCI(AUC value interpretation) Very Good Fair Poor
BCD(Bray-Curtis dissimilarity) 0.08333 0.04167 0.04167
BM(Informedness or bookmaker informedness) 0.77778 0.22222 0.16667
CEN(Confusion entropy) 0.25 0.49658 0.60442
DOR(Diagnostic odds ratio) None 4.0 2.0
DP(Discriminant power) None 0.33193 0.16597
DPI(Discriminant power interpretation) None Poor Poor
ERR(Error rate) 0.16667 0.25 0.41667
F0.5(F0.5 score) 0.65217 0.45455 0.57692
F1(F1 score - harmonic mean of precision and sensitivity) 0.75 0.4 0.54545
F2(F2 score) 0.88235 0.35714 0.51724
FDR(False discovery rate) 0.4 0.5 0.4
FN(False negative/miss/type 2 error) 0 2 3
FNR(Miss rate or false negative rate) 0.0 0.66667 0.5
FOR(False omission rate) 0.0 0.2 0.42857
FP(False positive/type 1 error/false alarm) 2 1 2
FPR(Fall-out or false positive rate) 0.22222 0.11111 0.33333
G(G-measure geometric mean of precision and sensitivity) 0.7746 0.40825 0.54772
GI(Gini index) 0.77778 0.22222 0.16667
GM(G-mean geometric mean of specificity and sensitivity) 0.88192 0.54433 0.57735
IBA(Index of balanced accuracy) 0.95062 0.13169 0.27778
IS(Information score) 1.26303 1.0 0.26303
J(Jaccard index) 0.6 0.25 0.375
LS(Lift score) 2.4 2.0 1.2
MCC(Matthews correlation coefficient) 0.68313 0.2582 0.16903
MCCI(Matthews correlation coefficient interpretation) Moderate Negligible Negligible
MCEN(Modified confusion entropy) 0.26439 0.5 0.6875
MK(Markedness) 0.6 0.3 0.17143
N(Condition negative) 9 9 6
NLR(Negative likelihood ratio) 0.0 0.75 0.75
NLRI(Negative likelihood ratio interpretation) Good Negligible Negligible
NPV(Negative predictive value) 1.0 0.8 0.57143
OP(Optimized precision) 0.70833 0.29545 0.44048
P(Condition positive or support) 3 3 6
PLR(Positive likelihood ratio) 4.5 3.0 1.5
PLRI(Positive likelihood ratio interpretation) Poor Poor Poor
POP(Population) 12 12 12
PPV(Precision or positive predictive value) 0.6 0.5 0.6
PRE(Prevalence) 0.25 0.25 0.5
Q(Yule Q - coefficient of colligation) None 0.6 0.33333
RACC(Random accuracy) 0.10417 0.04167 0.20833
RACCU(Random accuracy unbiased) 0.11111 0.0434 0.21007
TN(True negative/correct rejection) 7 8 4
TNR(Specificity or true negative rate) 0.77778 0.88889 0.66667
TON(Test outcome negative) 7 10 7
TOP(Test outcome positive) 5 2 5
TP(True positive/hit) 3 1 3
TPR(Sensitivity, recall, hit rate, or true positive rate) 1.0 0.33333 0.5
Y(Youden index) 0.77778 0.22222 0.16667
dInd(Distance index) 0.22222 0.67586 0.60093
sInd(Similarity index) 0.84287 0.52209 0.57508
<BLANKLINE>
>>> cm.relabel({0:"L1",1:"L2",2:"L3"})
>>> print(cm)
Predict L1 L2 L3
Actual
L1 3 0 0
<BLANKLINE>
L2 0 1 2
<BLANKLINE>
L3 2 1 3
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
Overall Statistics :
<BLANKLINE>
95% CI (0.30439,0.86228)
ACC Macro 0.72222
AUNP 0.66667
AUNU 0.69444
Bennett S 0.375
CBA 0.47778
Chi-Squared 6.6
Chi-Squared DF 4
Conditional Entropy 0.95915
Cramer V 0.5244
Cross Entropy 1.59352
F1 Macro 0.56515
F1 Micro 0.58333
Gwet AC1 0.38931
Hamming Loss 0.41667
Joint Entropy 2.45915
KL Divergence 0.09352
Kappa 0.35484
Kappa 95% CI (-0.07708,0.78675)
Kappa No Prevalence 0.16667
Kappa Standard Error 0.22036
Kappa Unbiased 0.34426
Lambda A 0.16667
Lambda B 0.42857
Mutual Information 0.52421
NIR 0.5
Overall ACC 0.58333
Overall CEN 0.46381
Overall J (1.225,0.40833)
Overall MCC 0.36667
Overall MCEN 0.51894
Overall RACC 0.35417
Overall RACCU 0.36458
P-Value 0.38721
PPV Macro 0.56667
PPV Micro 0.58333
Pearson C 0.59568
Phi-Squared 0.55
RCI 0.34947
RR 4.0
Reference Entropy 1.5
Response Entropy 1.48336
SOA1(Landis & Koch) Fair
SOA2(Fleiss) Poor
SOA3(Altman) Fair
SOA4(Cicchetti) Poor
SOA5(Cramer) Relatively Strong
SOA6(Matthews) Weak
Scott PI 0.34426
Standard Error 0.14232
TPR Macro 0.61111
TPR Micro 0.58333
Zero-one Loss 5
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes L1 L2 L3
ACC(Accuracy) 0.83333 0.75 0.58333
AGM(Adjusted geometric mean) 0.83729 0.692 0.60712
AM(Difference between automatic and manual classification) 2 -1 -1
AUC(Area under the roc curve) 0.88889 0.61111 0.58333
AUCI(AUC value interpretation) Very Good Fair Poor
BCD(Bray-Curtis dissimilarity) 0.08333 0.04167 0.04167
BM(Informedness or bookmaker informedness) 0.77778 0.22222 0.16667
CEN(Confusion entropy) 0.25 0.49658 0.60442
DOR(Diagnostic odds ratio) None 4.0 2.0
DP(Discriminant power) None 0.33193 0.16597
DPI(Discriminant power interpretation) None Poor Poor
ERR(Error rate) 0.16667 0.25 0.41667
F0.5(F0.5 score) 0.65217 0.45455 0.57692
F1(F1 score - harmonic mean of precision and sensitivity) 0.75 0.4 0.54545
F2(F2 score) 0.88235 0.35714 0.51724
FDR(False discovery rate) 0.4 0.5 0.4
FN(False negative/miss/type 2 error) 0 2 3
FNR(Miss rate or false negative rate) 0.0 0.66667 0.5
FOR(False omission rate) 0.0 0.2 0.42857
FP(False positive/type 1 error/false alarm) 2 1 2
FPR(Fall-out or false positive rate) 0.22222 0.11111 0.33333
G(G-measure geometric mean of precision and sensitivity) 0.7746 0.40825 0.54772
GI(Gini index) 0.77778 0.22222 0.16667
GM(G-mean geometric mean of specificity and sensitivity) 0.88192 0.54433 0.57735
IBA(Index of balanced accuracy) 0.95062 0.13169 0.27778
IS(Information score) 1.26303 1.0 0.26303
J(Jaccard index) 0.6 0.25 0.375
LS(Lift score) 2.4 2.0 1.2
MCC(Matthews correlation coefficient) 0.68313 0.2582 0.16903
MCCI(Matthews correlation coefficient interpretation) Moderate Negligible Negligible
MCEN(Modified confusion entropy) 0.26439 0.5 0.6875
MK(Markedness) 0.6 0.3 0.17143
N(Condition negative) 9 9 6
NLR(Negative likelihood ratio) 0.0 0.75 0.75
NLRI(Negative likelihood ratio interpretation) Good Negligible Negligible
NPV(Negative predictive value) 1.0 0.8 0.57143
OP(Optimized precision) 0.70833 0.29545 0.44048
P(Condition positive or support) 3 3 6
PLR(Positive likelihood ratio) 4.5 3.0 1.5
PLRI(Positive likelihood ratio interpretation) Poor Poor Poor
POP(Population) 12 12 12
PPV(Precision or positive predictive value) 0.6 0.5 0.6
PRE(Prevalence) 0.25 0.25 0.5
Q(Yule Q - coefficient of colligation) None 0.6 0.33333
RACC(Random accuracy) 0.10417 0.04167 0.20833
RACCU(Random accuracy unbiased) 0.11111 0.0434 0.21007
TN(True negative/correct rejection) 7 8 4
TNR(Specificity or true negative rate) 0.77778 0.88889 0.66667
TON(Test outcome negative) 7 10 7
TOP(Test outcome positive) 5 2 5
TP(True positive/hit) 3 1 3
TPR(Sensitivity, recall, hit rate, or true positive rate) 1.0 0.33333 0.5
Y(Youden index) 0.77778 0.22222 0.16667
dInd(Distance index) 0.22222 0.67586 0.60093
sInd(Similarity index) 0.84287 0.52209 0.57508
<BLANKLINE>
>>> cm.matrix == {'L2': {'L2': 1, 'L1': 0, 'L3': 2}, 'L1': {'L2': 0, 'L1': 3, 'L3': 0}, 'L3': {'L2': 1, 'L1': 2, 'L3': 3}}
True
>>> cm.normalized_matrix == {'L2': {'L2': 0.33333, 'L1': 0.0, 'L3': 0.66667}, 'L1': {'L2': 0.0, 'L1': 1.0, 'L3': 0.0}, 'L3': {'L2': 0.16667, 'L1': 0.33333, 'L3': 0.5}}
True
>>> cm.matrix == cm.table
True
>>> cm.normalized_matrix == cm.normalized_table
True
>>> cm.Y["L2"]
0.2222222222222221
>>> import numpy as np
>>> y_test = np.array([600, 200, 200, 200, 200, 200, 200, 200, 500, 500, 500, 200, 200, 200, 200, 200, 200, 200, 200, 200])
>>> y_pred = np.array([100, 200, 200, 100, 100, 200, 200, 200, 100, 200, 500, 100, 100, 100, 100, 100, 100, 100, 500, 200])
>>> cm=ConfusionMatrix(y_test, y_pred)
>>> print(cm)
Predict 100 200 500 600
Actual
100 0 0 0 0
<BLANKLINE>
200 9 6 1 0
<BLANKLINE>
500 1 1 1 0
<BLANKLINE>
600 1 0 0 0
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
Overall Statistics :
<BLANKLINE>
95% CI (0.14096,0.55904)
ACC Macro 0.675
AUNP None
AUNU None
Bennett S 0.13333
CBA 0.17708
Chi-Squared None
Chi-Squared DF 9
Conditional Entropy 1.23579
Cramer V None
Cross Entropy 1.70995
F1 Macro 0.23043
F1 Micro 0.35
Gwet AC1 0.19505
Hamming Loss 0.65
Joint Entropy 2.11997
KL Divergence None
Kappa 0.07801
Kappa 95% CI (-0.2185,0.37453)
Kappa No Prevalence -0.3
Kappa Standard Error 0.15128
Kappa Unbiased -0.12554
Lambda A 0.0
Lambda B 0.0
Mutual Information 0.10088
NIR 0.8
Overall ACC 0.35
Overall CEN 0.3648
Overall J (0.60294,0.15074)
Overall MCC 0.12642
Overall MCEN 0.37463
Overall RACC 0.295
Overall RACCU 0.4225
P-Value 1.0
PPV Macro None
PPV Micro 0.35
Pearson C None
Phi-Squared None
RCI 0.11409
RR 5.0
Reference Entropy 0.88418
Response Entropy 1.33667
SOA1(Landis & Koch) Slight
SOA2(Fleiss) Poor
SOA3(Altman) Poor
SOA4(Cicchetti) Poor
SOA5(Cramer) None
SOA6(Matthews) Negligible
Scott PI -0.12554
Standard Error 0.10665
TPR Macro None
TPR Micro 0.35
Zero-one Loss 13
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes 100 200 500 600
ACC(Accuracy) 0.45 0.45 0.85 0.95
AGM(Adjusted geometric mean) None 0.56694 0.7352 0
AM(Difference between automatic and manual classification) 11 -9 -1 -1
AUC(Area under the roc curve) None 0.5625 0.63725 0.5
AUCI(AUC value interpretation) None Poor Fair Poor
BCD(Bray-Curtis dissimilarity) 0.275 0.225 0.025 0.025
BM(Informedness or bookmaker informedness) None 0.125 0.27451 0.0
CEN(Confusion entropy) 0.33496 0.35708 0.53895 0.0
DOR(Diagnostic odds ratio) None 1.8 8.0 None
DP(Discriminant power) None 0.14074 0.4979 None
DPI(Discriminant power interpretation) None Poor Poor None
ERR(Error rate) 0.55 0.55 0.15 0.05
F0.5(F0.5 score) 0.0 0.68182 0.45455 0.0
F1(F1 score - harmonic mean of precision and sensitivity) 0.0 0.52174 0.4 0.0
F2(F2 score) 0.0 0.42254 0.35714 0.0
FDR(False discovery rate) 1.0 0.14286 0.5 None
FN(False negative/miss/type 2 error) 0 10 2 1
FNR(Miss rate or false negative rate) None 0.625 0.66667 1.0
FOR(False omission rate) 0.0 0.76923 0.11111 0.05
FP(False positive/type 1 error/false alarm) 11 1 1 0
FPR(Fall-out or false positive rate) 0.55 0.25 0.05882 0.0
G(G-measure geometric mean of precision and sensitivity) None 0.56695 0.40825 None
GI(Gini index) None 0.125 0.27451 0.0
GM(G-mean geometric mean of specificity and sensitivity) None 0.53033 0.56011 0.0
IBA(Index of balanced accuracy) None 0.17578 0.12303 0.0
IS(Information score) None 0.09954 1.73697 None
J(Jaccard index) 0.0 0.35294 0.25 0.0
LS(Lift score) None 1.07143 3.33333 None
MCC(Matthews correlation coefficient) None 0.10483 0.32673 None
MCCI(Matthews correlation coefficient interpretation) None Negligible Weak None
MCEN(Modified confusion entropy) 0.33496 0.37394 0.58028 0.0
MK(Markedness) 0.0 0.08791 0.38889 None
N(Condition negative) 20 4 17 19
NLR(Negative likelihood ratio) None 0.83333 0.70833 1.0
NLRI(Negative likelihood ratio interpretation) None Negligible Negligible Negligible
NPV(Negative predictive value) 1.0 0.23077 0.88889 0.95
OP(Optimized precision) None 0.11667 0.37308 -0.05
P(Condition positive or support) 0 16 3 1
PLR(Positive likelihood ratio) None 1.5 5.66667 None
PLRI(Positive likelihood ratio interpretation) None Poor Fair None
POP(Population) 20 20 20 20
PPV(Precision or positive predictive value) 0.0 0.85714 0.5 None
PRE(Prevalence) 0.0 0.8 0.15 0.05
Q(Yule Q - coefficient of colligation) None 0.28571 0.77778 None
RACC(Random accuracy) 0.0 0.28 0.015 0.0
RACCU(Random accuracy unbiased) 0.07563 0.33062 0.01562 0.00063
TN(True negative/correct rejection) 9 3 16 19
TNR(Specificity or true negative rate) 0.45 0.75 0.94118 1.0
TON(Test outcome negative) 9 13 18 20
TOP(Test outcome positive) 11 7 2 0
TP(True positive/hit) 0 6 1 0
TPR(Sensitivity, recall, hit rate, or true positive rate) None 0.375 0.33333 0.0
Y(Youden index) None 0.125 0.27451 0.0
dInd(Distance index) None 0.67315 0.66926 1.0
sInd(Similarity index) None 0.52401 0.52676 0.29289
<BLANKLINE>
>>> cm.stat()
Overall Statistics :
<BLANKLINE>
95% CI (0.14096,0.55904)
ACC Macro 0.675
AUNP None
AUNU None
Bennett S 0.13333
CBA 0.17708
Chi-Squared None
Chi-Squared DF 9
Conditional Entropy 1.23579
Cramer V None
Cross Entropy 1.70995
F1 Macro 0.23043
F1 Micro 0.35
Gwet AC1 0.19505
Hamming Loss 0.65
Joint Entropy 2.11997
KL Divergence None
Kappa 0.07801
Kappa 95% CI (-0.2185,0.37453)
Kappa No Prevalence -0.3
Kappa Standard Error 0.15128
Kappa Unbiased -0.12554
Lambda A 0.0
Lambda B 0.0
Mutual Information 0.10088
NIR 0.8
Overall ACC 0.35
Overall CEN 0.3648
Overall J (0.60294,0.15074)
Overall MCC 0.12642
Overall MCEN 0.37463
Overall RACC 0.295
Overall RACCU 0.4225
P-Value 1.0
PPV Macro None
PPV Micro 0.35
Pearson C None
Phi-Squared None
RCI 0.11409
RR 5.0
Reference Entropy 0.88418
Response Entropy 1.33667
SOA1(Landis & Koch) Slight
SOA2(Fleiss) Poor
SOA3(Altman) Poor
SOA4(Cicchetti) Poor
SOA5(Cramer) None
SOA6(Matthews) Negligible
Scott PI -0.12554
Standard Error 0.10665
TPR Macro None
TPR Micro 0.35
Zero-one Loss 13
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes 100 200 500 600
ACC(Accuracy) 0.45 0.45 0.85 0.95
AGM(Adjusted geometric mean) None 0.56694 0.7352 0
AM(Difference between automatic and manual classification) 11 -9 -1 -1
AUC(Area under the roc curve) None 0.5625 0.63725 0.5
AUCI(AUC value interpretation) None Poor Fair Poor
BCD(Bray-Curtis dissimilarity) 0.275 0.225 0.025 0.025
BM(Informedness or bookmaker informedness) None 0.125 0.27451 0.0
CEN(Confusion entropy) 0.33496 0.35708 0.53895 0.0
DOR(Diagnostic odds ratio) None 1.8 8.0 None
DP(Discriminant power) None 0.14074 0.4979 None
DPI(Discriminant power interpretation) None Poor Poor None
ERR(Error rate) 0.55 0.55 0.15 0.05
F0.5(F0.5 score) 0.0 0.68182 0.45455 0.0
F1(F1 score - harmonic mean of precision and sensitivity) 0.0 0.52174 0.4 0.0
F2(F2 score) 0.0 0.42254 0.35714 0.0
FDR(False discovery rate) 1.0 0.14286 0.5 None
FN(False negative/miss/type 2 error) 0 10 2 1
FNR(Miss rate or false negative rate) None 0.625 0.66667 1.0
FOR(False omission rate) 0.0 0.76923 0.11111 0.05
FP(False positive/type 1 error/false alarm) 11 1 1 0
FPR(Fall-out or false positive rate) 0.55 0.25 0.05882 0.0
G(G-measure geometric mean of precision and sensitivity) None 0.56695 0.40825 None
GI(Gini index) None 0.125 0.27451 0.0
GM(G-mean geometric mean of specificity and sensitivity) None 0.53033 0.56011 0.0
IBA(Index of balanced accuracy) None 0.17578 0.12303 0.0
IS(Information score) None 0.09954 1.73697 None
J(Jaccard index) 0.0 0.35294 0.25 0.0
LS(Lift score) None 1.07143 3.33333 None
MCC(Matthews correlation coefficient) None 0.10483 0.32673 None
MCCI(Matthews correlation coefficient interpretation) None Negligible Weak None
MCEN(Modified confusion entropy) 0.33496 0.37394 0.58028 0.0
MK(Markedness) 0.0 0.08791 0.38889 None
N(Condition negative) 20 4 17 19
NLR(Negative likelihood ratio) None 0.83333 0.70833 1.0
NLRI(Negative likelihood ratio interpretation) None Negligible Negligible Negligible
NPV(Negative predictive value) 1.0 0.23077 0.88889 0.95
OP(Optimized precision) None 0.11667 0.37308 -0.05
P(Condition positive or support) 0 16 3 1
PLR(Positive likelihood ratio) None 1.5 5.66667 None
PLRI(Positive likelihood ratio interpretation) None Poor Fair None
POP(Population) 20 20 20 20
PPV(Precision or positive predictive value) 0.0 0.85714 0.5 None
PRE(Prevalence) 0.0 0.8 0.15 0.05
Q(Yule Q - coefficient of colligation) None 0.28571 0.77778 None
RACC(Random accuracy) 0.0 0.28 0.015 0.0
RACCU(Random accuracy unbiased) 0.07563 0.33062 0.01562 0.00063
TN(True negative/correct rejection) 9 3 16 19
TNR(Specificity or true negative rate) 0.45 0.75 0.94118 1.0
TON(Test outcome negative) 9 13 18 20
TOP(Test outcome positive) 11 7 2 0
TP(True positive/hit) 0 6 1 0
TPR(Sensitivity, recall, hit rate, or true positive rate) None 0.375 0.33333 0.0
Y(Youden index) None 0.125 0.27451 0.0
dInd(Distance index) None 0.67315 0.66926 1.0
sInd(Similarity index) None 0.52401 0.52676 0.29289
<BLANKLINE>
>>> cm.stat(overall_param=["Kappa","Scott PI"],class_param=["TPR","TNR","ACC","AUC"])
Overall Statistics :
<BLANKLINE>
Kappa 0.07801
Scott PI -0.12554
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes 100 200 500 600
ACC(Accuracy) 0.45 0.45 0.85 0.95
AUC(Area under the roc curve) None 0.5625 0.63725 0.5
TNR(Specificity or true negative rate) 0.45 0.75 0.94118 1.0
TPR(Sensitivity, recall, hit rate, or true positive rate) None 0.375 0.33333 0.0
<BLANKLINE>
>>> cm.stat(overall_param=["Kappa","Scott PI"],class_param=["TPR","TNR","ACC","AUC"],class_name=[100])
Overall Statistics :
<BLANKLINE>
Kappa 0.07801
Scott PI -0.12554
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes 100
ACC(Accuracy) 0.45
AUC(Area under the roc curve) None
TNR(Specificity or true negative rate) 0.45
TPR(Sensitivity, recall, hit rate, or true positive rate) None
<BLANKLINE>
>>> cm.stat(overall_param=["Kappa","Scott PI"],class_param=["TPR","TNR","ACC","AUC"],class_name=[])
Overall Statistics :
<BLANKLINE>
Kappa 0.07801
Scott PI -0.12554
<BLANKLINE>
>>> cm.stat(overall_param=["Kappa","Scott PI"],class_param=[],class_name=[100])
Overall Statistics :
<BLANKLINE>
Kappa 0.07801
Scott PI -0.12554
<BLANKLINE>
>>> cm.stat(overall_param=["Kappa","Scott PI"],class_param=["TPR"],class_name=[100])
Overall Statistics :
<BLANKLINE>
Kappa 0.07801
Scott PI -0.12554
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes 100
TPR(Sensitivity, recall, hit rate, or true positive rate) None
<BLANKLINE>
>>> cm.stat(overall_param=[],class_param=["TPR"],class_name=[100])
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes 100
TPR(Sensitivity, recall, hit rate, or true positive rate) None
<BLANKLINE>
>>> cm.print_normalized_matrix()
Predict 100 200 500 600
Actual
100 0.0 0.0 0.0 0.0
200 0.5625 0.375 0.0625 0.0
500 0.33333 0.33333 0.33333 0.0
600 1.0 0.0 0.0 0.0
<BLANKLINE>
>>> cm.print_matrix()
Predict 100 200 500 600
Actual
100 0 0 0 0
200 9 6 1 0
500 1 1 1 0
600 1 0 0 0
<BLANKLINE>
>>> cm.print_matrix(one_vs_all=True,class_name=200)
Predict 200 ~
Actual
200 6 10
~ 1 3
<BLANKLINE>
>>> cm.print_normalized_matrix(one_vs_all=True,class_name=200)
Predict 200 ~
Actual
200 0.375 0.625
~ 0.25 0.75
<BLANKLINE>
>>> def activation(i):
... if i<0.7:
... return 1
... else:
... return 0
>>> cm_6 = ConfusionMatrix([0,0,1,0],[0.87,0.34,0.9,0.12],threshold=activation, transpose=2)
>>> cm_6.print_matrix()
Predict 0 1
Actual
0 1 2
1 1 0
>>> cm = ConfusionMatrix(matrix={1:{1:0,2:0},2:{1:0,2:0}})
>>> cm
pycm.ConfusionMatrix(classes: [1, 2])
>>> cm = ConfusionMatrix(matrix={"Class1":{"Class1":9,"Class2":3,"Class3":0},"Class2":{"Class1":3,"Class2":5,"Class3":1},"Class3":{"Class1":1,"Class2":1,"Class3":4}})
>>> print(cm)
Predict Class1 Class2 Class3
Actual
Class1 9 3 0
<BLANKLINE>
Class2 3 5 1
<BLANKLINE>
Class3 1 1 4
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
Overall Statistics :
<BLANKLINE>
95% CI (0.48885,0.84448)
ACC Macro 0.77778
AUNP 0.73175
AUNU 0.73929
Bennett S 0.5
CBA 0.63818
Chi-Squared 15.52564
Chi-Squared DF 4
Conditional Entropy 1.08926
Cramer V 0.5362
Cross Entropy 1.53762
F1 Macro 0.66761
F1 Micro 0.66667
Gwet AC1 0.51229
Hamming Loss 0.33333
Joint Entropy 2.61975
KL Divergence 0.00713
Kappa 0.47403
Kappa 95% CI (0.19345,0.7546)
Kappa No Prevalence 0.33333
Kappa Standard Error 0.14315
Kappa Unbiased 0.47346
Lambda A 0.4
Lambda B 0.35714
Mutual Information 0.39731
NIR 0.44444
Overall ACC 0.66667
Overall CEN 0.52986
Overall J (1.51854,0.50618)
Overall MCC 0.47511
Overall MCEN 0.65286
Overall RACC 0.36626
Overall RACCU 0.36694
P-Value 0.01667
PPV Macro 0.68262
PPV Micro 0.66667
Pearson C 0.60423
Phi-Squared 0.57502
RCI 0.2596
RR 9.0
Reference Entropy 1.53049
Response Entropy 1.48657
SOA1(Landis & Koch) Moderate
SOA2(Fleiss) Intermediate to Good
SOA3(Altman) Moderate
SOA4(Cicchetti) Fair
SOA5(Cramer) Relatively Strong
SOA6(Matthews) Weak
Scott PI 0.47346
Standard Error 0.09072
TPR Macro 0.65741
TPR Micro 0.66667
Zero-one Loss 9
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes Class1 Class2 Class3
ACC(Accuracy) 0.74074 0.7037 0.88889
AGM(Adjusted geometric mean) 0.73866 0.70552 0.86488
AM(Difference between automatic and manual classification) 1 0 -1
AUC(Area under the roc curve) 0.74167 0.66667 0.80952
AUCI(AUC value interpretation) Good Fair Very Good
BCD(Bray-Curtis dissimilarity) 0.01852 0.0 0.01852
BM(Informedness or bookmaker informedness) 0.48333 0.33333 0.61905
CEN(Confusion entropy) 0.45994 0.66249 0.47174
DOR(Diagnostic odds ratio) 8.25 4.375 40.0
DP(Discriminant power) 0.50527 0.35339 0.88326
DPI(Discriminant power interpretation) Poor Poor Poor
ERR(Error rate) 0.25926 0.2963 0.11111
F0.5(F0.5 score) 0.70312 0.55556 0.76923
F1(F1 score - harmonic mean of precision and sensitivity) 0.72 0.55556 0.72727
F2(F2 score) 0.7377 0.55556 0.68966
FDR(False discovery rate) 0.30769 0.44444 0.2
FN(False negative/miss/type 2 error) 3 4 2
FNR(Miss rate or false negative rate) 0.25 0.44444 0.33333
FOR(False omission rate) 0.21429 0.22222 0.09091
FP(False positive/type 1 error/false alarm) 4 4 1
FPR(Fall-out or false positive rate) 0.26667 0.22222 0.04762
G(G-measure geometric mean of precision and sensitivity) 0.72058 0.55556 0.7303
GI(Gini index) 0.48333 0.33333 0.61905
GM(G-mean geometric mean of specificity and sensitivity) 0.74162 0.65734 0.79682
IBA(Index of balanced accuracy) 0.55917 0.33608 0.45351
IS(Information score) 0.63941 0.73697 1.848
J(Jaccard index) 0.5625 0.38462 0.57143
LS(Lift score) 1.55769 1.66667 3.6
MCC(Matthews correlation coefficient) 0.48067 0.33333 0.66254
MCCI(Matthews correlation coefficient interpretation) Weak Weak Moderate
MCEN(Modified confusion entropy) 0.57782 0.77284 0.60158
MK(Markedness) 0.47802 0.33333 0.70909
N(Condition negative) 15 18 21
NLR(Negative likelihood ratio) 0.34091 0.57143 0.35
NLRI(Negative likelihood ratio interpretation) Poor Negligible Poor
NPV(Negative predictive value) 0.78571 0.77778 0.90909
OP(Optimized precision) 0.7295 0.53704 0.71242
P(Condition positive or support) 12 9 6
PLR(Positive likelihood ratio) 2.8125 2.5 14.0
PLRI(Positive likelihood ratio interpretation) Poor Poor Good
POP(Population) 27 27 27
PPV(Precision or positive predictive value) 0.69231 0.55556 0.8
PRE(Prevalence) 0.44444 0.33333 0.22222
Q(Yule Q - coefficient of colligation) 0.78378 0.62791 0.95122
RACC(Random accuracy) 0.21399 0.11111 0.04115
RACCU(Random accuracy unbiased) 0.21433 0.11111 0.0415
TN(True negative/correct rejection) 11 14 20
TNR(Specificity or true negative rate) 0.73333 0.77778 0.95238
TON(Test outcome negative) 14 18 22
TOP(Test outcome positive) 13 9 5
TP(True positive/hit) 9 5 4
TPR(Sensitivity, recall, hit rate, or true positive rate) 0.75 0.55556 0.66667
Y(Youden index) 0.48333 0.33333 0.61905
dInd(Distance index) 0.36553 0.4969 0.33672
sInd(Similarity index) 0.74153 0.64864 0.7619
<BLANKLINE>
>>> cm = ConfusionMatrix(matrix={"Class1":{"Class1":9,"Class2":3,"Class3":1},"Class2":{"Class1":3,"Class2":5,"Class3":1},"Class3":{"Class1":0,"Class2":1,"Class3":4}},transpose=True)
>>> print(cm)
Predict Class1 Class2 Class3
Actual
Class1 9 3 0
<BLANKLINE>
Class2 3 5 1
<BLANKLINE>
Class3 1 1 4
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
Overall Statistics :
<BLANKLINE>
95% CI (0.48885,0.84448)
ACC Macro 0.77778
AUNP 0.73175
AUNU 0.73929
Bennett S 0.5
CBA 0.63818
Chi-Squared 15.52564
Chi-Squared DF 4
Conditional Entropy 1.08926
Cramer V 0.5362
Cross Entropy 1.53762
F1 Macro 0.66761
F1 Micro 0.66667
Gwet AC1 0.51229
Hamming Loss 0.33333
Joint Entropy 2.61975
KL Divergence 0.00713
Kappa 0.47403
Kappa 95% CI (0.19345,0.7546)
Kappa No Prevalence 0.33333
Kappa Standard Error 0.14315
Kappa Unbiased 0.47346
Lambda A 0.4
Lambda B 0.35714
Mutual Information 0.39731
NIR 0.44444
Overall ACC 0.66667
Overall CEN 0.52986
Overall J (1.51854,0.50618)
Overall MCC 0.47511
Overall MCEN 0.65286
Overall RACC 0.36626
Overall RACCU 0.36694
P-Value 0.01667
PPV Macro 0.68262
PPV Micro 0.66667
Pearson C 0.60423
Phi-Squared 0.57502
RCI 0.2596
RR 9.0
Reference Entropy 1.53049
Response Entropy 1.48657
SOA1(Landis & Koch) Moderate
SOA2(Fleiss) Intermediate to Good
SOA3(Altman) Moderate
SOA4(Cicchetti) Fair
SOA5(Cramer) Relatively Strong
SOA6(Matthews) Weak
Scott PI 0.47346
Standard Error 0.09072
TPR Macro 0.65741
TPR Micro 0.66667
Zero-one Loss 9
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes Class1 Class2 Class3
ACC(Accuracy) 0.74074 0.7037 0.88889
AGM(Adjusted geometric mean) 0.73866 0.70552 0.86488
AM(Difference between automatic and manual classification) 1 0 -1
AUC(Area under the roc curve) 0.74167 0.66667 0.80952
AUCI(AUC value interpretation) Good Fair Very Good
BCD(Bray-Curtis dissimilarity) 0.01852 0.0 0.01852
BM(Informedness or bookmaker informedness) 0.48333 0.33333 0.61905
CEN(Confusion entropy) 0.45994 0.66249 0.47174
DOR(Diagnostic odds ratio) 8.25 4.375 40.0
DP(Discriminant power) 0.50527 0.35339 0.88326
DPI(Discriminant power interpretation) Poor Poor Poor
ERR(Error rate) 0.25926 0.2963 0.11111
F0.5(F0.5 score) 0.70312 0.55556 0.76923
F1(F1 score - harmonic mean of precision and sensitivity) 0.72 0.55556 0.72727
F2(F2 score) 0.7377 0.55556 0.68966
FDR(False discovery rate) 0.30769 0.44444 0.2
FN(False negative/miss/type 2 error) 3 4 2
FNR(Miss rate or false negative rate) 0.25 0.44444 0.33333
FOR(False omission rate) 0.21429 0.22222 0.09091
FP(False positive/type 1 error/false alarm) 4 4 1
FPR(Fall-out or false positive rate) 0.26667 0.22222 0.04762
G(G-measure geometric mean of precision and sensitivity) 0.72058 0.55556 0.7303
GI(Gini index) 0.48333 0.33333 0.61905
GM(G-mean geometric mean of specificity and sensitivity) 0.74162 0.65734 0.79682
IBA(Index of balanced accuracy) 0.55917 0.33608 0.45351
IS(Information score) 0.63941 0.73697 1.848
J(Jaccard index) 0.5625 0.38462 0.57143
LS(Lift score) 1.55769 1.66667 3.6
MCC(Matthews correlation coefficient) 0.48067 0.33333 0.66254
MCCI(Matthews correlation coefficient interpretation) Weak Weak Moderate
MCEN(Modified confusion entropy) 0.57782 0.77284 0.60158
MK(Markedness) 0.47802 0.33333 0.70909
N(Condition negative) 15 18 21
NLR(Negative likelihood ratio) 0.34091 0.57143 0.35
NLRI(Negative likelihood ratio interpretation) Poor Negligible Poor
NPV(Negative predictive value) 0.78571 0.77778 0.90909
OP(Optimized precision) 0.7295 0.53704 0.71242
P(Condition positive or support) 12 9 6
PLR(Positive likelihood ratio) 2.8125 2.5 14.0
PLRI(Positive likelihood ratio interpretation) Poor Poor Good
POP(Population) 27 27 27
PPV(Precision or positive predictive value) 0.69231 0.55556 0.8
PRE(Prevalence) 0.44444 0.33333 0.22222
Q(Yule Q - coefficient of colligation) 0.78378 0.62791 0.95122
RACC(Random accuracy) 0.21399 0.11111 0.04115
RACCU(Random accuracy unbiased) 0.21433 0.11111 0.0415
TN(True negative/correct rejection) 11 14 20
TNR(Specificity or true negative rate) 0.73333 0.77778 0.95238
TON(Test outcome negative) 14 18 22
TOP(Test outcome positive) 13 9 5
TP(True positive/hit) 9 5 4
TPR(Sensitivity, recall, hit rate, or true positive rate) 0.75 0.55556 0.66667
Y(Youden index) 0.48333 0.33333 0.61905
dInd(Distance index) 0.36553 0.4969 0.33672
sInd(Similarity index) 0.74153 0.64864 0.7619
<BLANKLINE>
>>> y_actu = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2]
>>> y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2]
>>> cm = ConfusionMatrix(y_actu, y_pred, sample_weight=[2, 2, 2, 2, 3, 1, 1, 2, 2, 1, 1, 2])
>>> print(cm)
Predict 0 1 2
Actual
0 6 0 0
<BLANKLINE>
1 0 1 2
<BLANKLINE>
2 4 2 6
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
Overall Statistics :
<BLANKLINE>
95% CI (0.41134,0.82675)
ACC Macro 0.74603
AUNP 0.7
AUNU 0.70556
Bennett S 0.42857
CBA 0.47778
Chi-Squared 10.44167
Chi-Squared DF 4
Conditional Entropy 0.96498
Cramer V 0.49861
Cross Entropy 1.50249
F1 Macro 0.56111
F1 Micro 0.61905
Gwet AC1 0.45277
Hamming Loss 0.38095
Joint Entropy 2.34377
KL Divergence 0.1237
Kappa 0.3913
Kappa 95% CI (0.05943,0.72318)
Kappa No Prevalence 0.2381
Kappa Standard Error 0.16932
Kappa Unbiased 0.37313
Lambda A 0.22222
Lambda B 0.36364
Mutual Information 0.47618
NIR 0.57143
Overall ACC 0.61905
Overall CEN 0.43947
Overall J (1.22857,0.40952)
Overall MCC 0.41558
Overall MCEN 0.50059
Overall RACC 0.37415
Overall RACCU 0.39229
P-Value 0.41709
PPV Macro 0.56111
PPV Micro 0.61905
Pearson C 0.57628
Phi-Squared 0.49722
RCI 0.34536
RR 7.0
Reference Entropy 1.37878
Response Entropy 1.44117
SOA1(Landis & Koch) Fair
SOA2(Fleiss) Poor
SOA3(Altman) Fair
SOA4(Cicchetti) Poor
SOA5(Cramer) Relatively Strong
SOA6(Matthews) Weak
Scott PI 0.37313
Standard Error 0.10597
TPR Macro 0.61111
TPR Micro 0.61905
Zero-one Loss 8
<BLANKLINE>
Class Statistics :
<BLANKLINE>
Classes 0 1 2
ACC(Accuracy) 0.80952 0.80952 0.61905
AGM(Adjusted geometric mean) 0.80509 0.70336 0.66986
AM(Difference between automatic and manual classification) 4 0 -4
AUC(Area under the roc curve) 0.86667 0.61111 0.63889
AUCI(AUC value interpretation) Very Good Fair Fair
BCD(Bray-Curtis dissimilarity) 0.09524 0.0 0.09524
BM(Informedness or bookmaker informedness) 0.73333 0.22222 0.27778
CEN(Confusion entropy) 0.25 0.52832 0.56439
DOR(Diagnostic odds ratio) None 4.0 3.5
DP(Discriminant power) None 0.33193 0.29996
DPI(Discriminant power interpretation) None Poor Poor
ERR(Error rate) 0.19048 0.19048 0.38095
F0.5(F0.5 score) 0.65217 0.33333 0.68182
F1(F1 score - harmonic mean of precision and sensitivity) 0.75 0.33333 0.6
F2(F2 score) 0.88235 0.33333 0.53571
FDR(False discovery rate) 0.4 0.66667 0.25
FN(False negative/miss/type 2 error) 0 2 6
FNR(Miss rate or false negative rate) 0.0 0.66667 0.5
FOR(False omission rate) 0.0 0.11111 0.46154
FP(False positive/type 1 error/false alarm) 4 2 2
FPR(Fall-out or false positive rate) 0.26667 0.11111 0.22222
G(G-measure geometric mean of precision and sensitivity) 0.7746 0.33333 0.61237
GI(Gini index) 0.73333 0.22222 0.27778
GM(G-mean geometric mean of specificity and sensitivity) 0.85635 0.54433 0.62361
IBA(Index of balanced accuracy) 0.92889 0.13169 0.28086
IS(Information score) 1.07039 1.22239 0.39232
J(Jaccard index) 0.6 0.2 0.42857
LS(Lift score) 2.1 2.33333 1.3125
MCC(Matthews correlation coefficient) 0.66332 0.22222 0.28307
MCCI(Matthews correlation coefficient interpretation) Moderate Negligible Negligible
MCEN(Modified confusion entropy) 0.26439 0.52877 0.65924
MK(Markedness) 0.6 0.22222 0.28846
N(Condition negative) 15 18 9
NLR(Negative likelihood ratio) 0.0 0.75 0.64286
NLRI(Negative likelihood ratio interpretation) Good Negligible Negligible
NPV(Negative predictive value) 1.0 0.88889 0.53846
OP(Optimized precision) 0.65568 0.35498 0.40166
P(Condition positive or support) 6 3 12