Checking that the notebook is running on Google Colab or not.
import sys
try:
import google.colab
!{sys.executable} -m pip -q -q install pycm
except:
pass
from pycm import ConfusionMatrix
case1 = ConfusionMatrix(matrix={"Class1": {"Class1": 26900, "Class2": 40}, "Class2": {"Class1": 25, "Class2": 500}})
case1.print_normalized_matrix()
print('ACC:', case1.ACC)
print('MCC:', case1.MCC)
print('CEN:', case1.CEN)
print('MCEN:', case1.MCEN)
print('DP:', case1.DP)
print('Kappa:', case1.Kappa)
print('RCI:', case1.RCI)
print('SOA1:', case1.SOA1)
case2 = ConfusionMatrix(matrix={"Class1": {"Class1": 29600, "Class2": 40}, "Class2": {"Class1": 500, "Class2": 25}})
case2.print_normalized_matrix()
print('ACC:', case2.ACC)
print('MCC:', case2.MCC)
print('CEN:', case2.CEN)
print('MCEN:', case2.MCEN)
print('DP:', case2.DP)
print('Kappa:', case2.Kappa)
print('RCI:', case2.RCI)
print('SOA1:', case2.SOA1)
case3 = ConfusionMatrix(matrix={"Class1": {"Class1": 40, "Class2": 26900}, "Class2": {"Class1": 25, "Class2": 500}})
case3.print_normalized_matrix()
print('ACC:', case3.ACC)
print('MCC:', case3.MCC)
print('CEN:', case3.CEN)
print('MCEN:', case3.MCEN)
print('DP:', case3.DP)
print('Kappa:', case3.Kappa)
print('RCI:', case3.RCI)
print('SOA1:', case3.SOA1)
case1 = ConfusionMatrix(
matrix={
"Class1": {"Class1": 4, "Class2": 0, "Class3": 0, "Class4": 1},
"Class2": {"Class1": 0, "Class2": 4, "Class3": 1, "Class4": 0},
"Class3": {"Class1": 0, "Class2": 1, "Class3": 4, "Class4": 0},
"Class4": {"Class1": 0, "Class2": 0, "Class3": 1, "Class4": 40000}})
case1.print_normalized_matrix()
print('ACC:', case1.ACC)
print('MCC:', case1.MCC)
print('CEN:', case1.CEN)
print('MCEN:', case1.MCEN)
print('DP:', case1.DP)
print('Kappa:', case1.Kappa)
print('RCI:', case1.RCI)
print('SOA1:', case1.SOA1)
case2 = ConfusionMatrix(
matrix={
"Class1": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class2": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class3": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class4": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1}})
case2.print_normalized_matrix()
print('ACC:', case2.ACC)
print('MCC:', case2.MCC)
print('CEN:', case2.CEN)
print('MCEN:', case2.MCEN)
print('DP:', case2.DP)
print('Kappa:', case2.Kappa)
print('RCI:', case2.RCI)
print('SOA1:', case2.SOA1)
case3 = ConfusionMatrix(
matrix={
"Class1": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class2": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class3": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class4": {"Class1": 10, "Class2": 1, "Class3": 1, "Class4": 1}})
case3.print_normalized_matrix()
print('ACC:', case3.ACC)
print('MCC:', case3.MCC)
print('CEN:', case3.CEN)
print('MCEN:', case3.MCEN)
print('DP:', case3.DP)
print('Kappa:', case3.Kappa)
print('RCI:', case3.RCI)
print('SOA1:', case3.SOA1)
case4 = ConfusionMatrix(
matrix={
"Class1": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class2": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class3": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class4": {"Class1": 10000, "Class2": 1, "Class3": 1, "Class4": 1}})
case3.print_normalized_matrix()
print('ACC:', case4.ACC)
print('MCC:', case4.MCC)
print('CEN:', case4.CEN)
print('MCEN:', case4.MCEN)
print('DP:', case4.DP)
print('Kappa:', case4.Kappa)
print('RCI:', case4.RCI)
print('SOA1:', case4.SOA1)
case5 = ConfusionMatrix(
matrix={
"Class1": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class2": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class3": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class4": {"Class1": 10, "Class2": 10, "Class3": 10, "Class4": 10}})
case5.print_normalized_matrix()
print('ACC:', case5.ACC)
print('MCC:', case5.MCC)
print('CEN:', case5.CEN)
print('MCEN:', case5.MCEN)
print('DP:', case5.DP)
print('Kappa:', case5.Kappa)
print('RCI:', case5.RCI)
print('SOA1:', case5.SOA1)
case6 = ConfusionMatrix(
matrix={
"Class1": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class2": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class3": {"Class1": 1, "Class2": 1, "Class3": 1, "Class4": 1},
"Class4": {"Class1": 10000, "Class2": 10000, "Class3": 10000, "Class4": 10000}})
case6.print_normalized_matrix()
print('ACC:', case6.ACC)
print('MCC:', case6.MCC)
print('CEN:', case6.CEN)
print('MCEN:', case6.MCEN)
print('DP:', case6.DP)
print('Kappa:', case6.Kappa)
print('RCI:', case6.RCI)
print('SOA1:', case6.SOA1)