Create Confusion Matrix

1. Load dataset(csv)
2. Split dataset to X_train,X_test,y_train,y_test
3. Run classifier, by .fit(X_train,y_train)
4. Impact on the results, by .predict(X_test)
5. Import confusion_matrix and Create-> cm = confusion_matrix(y_test, y_pred)

In [1]:
import pandas as pd
import numpy as np
import pickle
import xlwt
import matplotlib.pyplot as plt
from sklearn.datasets import make_classification
from sklearn.ensemble import RandomForestClassifier
from sklearn.cross_validation import cross_val_score
from sklearn.cross_validation import train_test_split
from sklearn.metrics import confusion_matrix
from sklearn.cross_validation import KFold
from sklearn.metrics import precision_score

In [2]:
df_file = pd.read_csv('../data/df_dropSub_less20_dropNaResult.csv',delimiter=",", skip_blank_lines = True, 
                 error_bad_lines=False)
df_file = df_file.drop('Unnamed: 0',axis=1)
df_file = df_file.fillna(0)
df_file = df_file.replace(['A', 'B+', 'B', 'C+', 'C' , 'D+' , 'D' , 'F' , 'W' , 'S' , 'S#' , 'U' , 'U#'], 
                     [8, 7, 7, 6 , 6, 5, 5, 4, 3, 2, 2, 1, 1])

In [3]:
df_file


Out[3]:
Unnamed: 0.1 3COURSEID 4RESULT 0STUDENTID 1ACADYEAR 2SEMESTER AT316 AT326 BA291 CJ315 ... TA395 TH161 TU100 TU110 TU120 TU122 TU130 TU154 PROVINCEID SCHOOLGPA
0 0 CS101 6 316644 2552 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 12 3.32
1 1 CS102 6 316644 2552 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 12 3.32
2 2 EL171 5 316644 2552 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 12 3.32
3 3 SC135 4 316644 2552 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 12 3.32
4 4 SC185 6 316644 2552 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 12 3.32
5 5 TH161 6 316644 2552 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 12 3.32
6 6 TU154 5 316644 2552 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 12 3.32
7 7 CS111 5 316644 2552 2 0 0 0 0 ... 0 6 0 0 0 0 0 5 12 3.32
8 8 EL172 4 316644 2552 2 0 0 0 0 ... 0 6 0 0 0 0 0 5 12 3.32
9 9 MA211 4 316644 2552 2 0 0 0 0 ... 0 6 0 0 0 0 0 5 12 3.32
10 10 PY228 7 316644 2552 2 0 0 0 0 ... 0 6 0 0 0 0 0 5 12 3.32
11 11 TU110 6 316644 2552 2 0 0 0 0 ... 0 6 0 0 0 0 0 5 12 3.32
12 12 TU120 5 316644 2552 2 0 0 0 0 ... 0 6 0 0 0 0 0 5 12 3.32
13 13 TU130 7 316644 2552 2 0 0 0 0 ... 0 6 0 0 0 0 0 5 12 3.32
14 14 TU122 7 316644 2552 3 0 0 0 0 ... 0 6 0 6 5 0 7 5 12 3.32
15 15 AT326 8 316644 2553 1 0 0 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
16 16 CS213 6 316644 2553 1 0 0 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
17 17 CS214 7 316644 2553 1 0 0 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
18 18 CS222 7 316644 2553 1 0 0 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
19 19 CS223 7 316644 2553 1 0 0 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
20 20 CS284 7 316644 2553 1 0 0 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
21 21 MA211 5 316644 2553 1 0 0 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
22 22 SW111 5 316644 2553 1 0 0 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
23 23 AT316 7 316644 2553 2 0 8 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
24 24 CS251 6 316644 2553 2 0 8 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
25 25 CS261 7 316644 2553 2 0 8 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
26 26 CS281 7 316644 2553 2 0 8 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
27 27 MA332 6 316644 2553 2 0 8 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
28 28 SC135 6 316644 2553 2 0 8 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
29 29 ST216 6 316644 2553 2 0 8 0 0 ... 0 6 0 6 5 7 7 5 12 3.32
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
27965 31292 EL070 2 447240 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 48 3.75
27966 31293 MA211 4 447240 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 48 3.75
27967 31294 ST216 4 447240 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 48 3.75
27968 31295 TH161 6 447240 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 48 3.75
27969 31296 TU154 4 447240 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 48 3.75
27970 31297 CS101 5 447241 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 13 2.60
27971 31298 CS102 5 447241 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 13 2.60
27972 31299 CS105 5 447241 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 13 2.60
27973 31300 EL070 2 447241 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 13 2.60
27974 31301 MA211 3 447241 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 13 2.60
27975 31302 ST216 3 447241 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 13 2.60
27976 31303 TH161 5 447241 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 13 2.60
27977 31304 TU154 3 447241 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 13 2.60
27978 31313 CS101 5 447242 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 34 2.93
27979 31314 CS102 5 447242 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 34 2.93
27980 31315 CS105 5 447242 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 34 2.93
27981 31316 EL171 3 447242 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 34 2.93
27982 31317 MA211 3 447242 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 34 2.93
27983 31318 ST216 3 447242 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 34 2.93
27984 31319 TH161 6 447242 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 34 2.93
27985 31320 TU154 5 447242 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 34 2.93
27986 31325 SC185 3 447242 2557 2 0 0 0 0 ... 0 6 0 0 0 0 0 5 34 2.93
27987 31329 CS101 4 447243 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 84 2.08
27988 31330 CS102 4 447243 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 84 2.08
27989 31331 CS105 4 447243 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 84 2.08
27990 31332 EL070 1 447243 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 84 2.08
27991 31333 MA211 4 447243 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 84 2.08
27992 31334 ST216 4 447243 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 84 2.08
27993 31335 TH161 4 447243 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 84 2.08
27994 31336 TU154 4 447243 2557 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 84 2.08

27995 rows × 119 columns


In [4]:
count_courseId = df_file["3COURSEID"].value_counts() 
more20 = count_courseId

headers=list(df_file.columns.values)
subjects = []
countSub = 0

In [5]:
count = 0
subjects.sort()
precision_rf={}
df_precision = more20.drop('CS231').copy()

list_allsub = df_file.columns[4:]
allSubject_df = pd.DataFrame(columns=[subjects],index=[list_allsub])
top10_df = pd.DataFrame(columns=[subjects])

In [6]:
headers=list(df_file.columns.values)
subjects = []
countSub = 0
#Create dictionary of list subjects
for sub in df_file[headers[1]]:
    if sub not in subjects:
        subjects.append(sub)
        countSub = countSub+1

In [7]:
subjects.sort()

In [8]:
subjects.remove('CS231')

In [9]:
len(subjects)


Out[9]:
110

In [16]:
subject = 'MA211'
df_sub = df_file[df_file['3COURSEID'] == subject]
df_sub = df_sub.iloc[np.random.permutation(len(df_sub))]
count_enrollment = df_sub['3COURSEID'].value_counts()
#print "Number of %s enrollment: %s"%(subject,count_enrollment)

A = df_sub.as_matrix()
X = A[:,6:116]
X = X.astype(np.int64, copy=False)
y = A[:,2]
y = y.astype(np.int64, copy=False)

In [17]:
subject


Out[17]:
'MA211'

In [18]:
X


Out[18]:
array([[0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       ..., 
       [0, 0, 0, ..., 8, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0]], dtype=int64)

In [19]:
X.shape


Out[19]:
(1068L, 110L)

In [20]:
y


Out[20]:
array([3, 6, 3, ..., 6, 3, 5], dtype=int64)

In [21]:
y.shape


Out[21]:
(1068L,)

In [232]:
# Split the data into a training set and a test set
X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.2,random_state=0)

In [233]:
X_train


Out[233]:
array([[0, 0, 0, ..., 0, 6, 4],
       [0, 0, 0, ..., 0, 0, 3],
       [0, 7, 0, ..., 7, 6, 5],
       ..., 
       [0, 0, 0, ..., 0, 0, 6],
       [0, 0, 0, ..., 6, 0, 7],
       [0, 0, 0, ..., 0, 0, 7]], dtype=int64)

In [234]:
X_train.shape


Out[234]:
(113L, 110L)

In [235]:
X_test


Out[235]:
array([[0, 8, 0, ..., 0, 6, 6],
       [0, 0, 0, ..., 0, 0, 8],
       [0, 0, 0, ..., 0, 7, 6],
       ..., 
       [0, 0, 0, ..., 6, 0, 6],
       [0, 0, 0, ..., 0, 0, 6],
       [0, 8, 0, ..., 0, 0, 5]], dtype=int64)

In [236]:
X_test.shape


Out[236]:
(29L, 110L)

In [97]:
X_train.shape


Out[97]:
(266L, 110L)

In [98]:
y_train


Out[98]:
array([8, 8, 7, 8, 8, 8, 8, 7, 8, 8, 8, 6, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8,
       8, 8, 8, 7, 8, 8, 8, 8, 8, 7, 8, 8, 8, 7, 8, 7, 7, 8, 8, 8, 8, 7, 8,
       7, 7, 8, 8, 8, 8, 8, 7, 7, 7, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8,
       8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 7, 7, 8,
       8, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7,
       8, 7, 8, 8, 8, 8, 8, 8, 8, 6, 8, 8, 8, 8, 8, 7, 7, 8, 8, 8, 7, 8, 8,
       8, 8, 8, 8, 8, 7, 8, 8, 7, 8, 8, 8, 7, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8,
       8, 8, 7, 7, 8, 7, 8, 8, 8, 7, 8, 7, 8, 8, 7, 7, 8, 8, 8, 8, 8, 8, 8,
       8, 8, 8, 8, 8, 8, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8,
       8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 8, 6, 8, 8, 7, 8, 8, 8, 8, 8, 8, 7, 7,
       8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 8, 7, 8, 8, 8, 8, 7, 8, 8,
       8, 6, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8], dtype=int64)

In [99]:
y_train.shape


Out[99]:
(266L,)

In [100]:
y_test


Out[100]:
array([8, 7, 8, 7, 8, 7, 8, 8, 8, 8, 8, 7, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8,
       8, 7, 7, 7, 7, 8, 7, 8, 8, 8, 7, 7, 8, 7, 8, 7, 6, 8, 8, 8, 7, 6, 8,
       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8], dtype=int64)

In [101]:
y_test.shape


Out[101]:
(67L,)

In [18]:
forest = RandomForestClassifier(n_estimators=10, max_depth=None, 
            min_samples_split=1, random_state=None, max_features=None)
clf = forest.fit(X, y)

In [ ]:


In [109]:
cm


Out[109]:
array([[ 0,  0,  2],
       [ 0,  1, 10],
       [ 0,  4, 49]])

In [104]:
X_train


Out[104]:
array([[0, 0, 0, ..., 0, 6, 6],
       [0, 0, 0, ..., 0, 6, 6],
       [0, 7, 6, ..., 0, 6, 5],
       ..., 
       [0, 0, 0, ..., 0, 7, 6],
       [0, 8, 0, ..., 8, 6, 5],
       [0, 7, 0, ..., 5, 6, 6]], dtype=int64)

In [61]:
len(X_train)


Out[61]:
855

In [24]:
y_pred = clf.predict(X)

In [25]:
y_pred.shape


Out[25]:
(765L,)

In [26]:
# Compute confusion matrix
cm = confusion_matrix(y, y_pred)
print('Confusion matrix, without normalization')
print(cm)
plt.figure()


Confusion matrix, without normalization
[[ 24   2   6   0   0   0]
 [  0  90   9   1   0   0]
 [  1   3 171  18   2   0]
 [  1   2  17 273   2   2]
 [  0   0   4  12  78   1]
 [  0   0   0   2   3  41]]
Out[26]:
<matplotlib.figure.Figure at 0x1ca9cf28>

In [20]:
Grade = ['A', 'B', 'C' , 'D' , 'F' , 'W' , 'S' , 'U' ,'na']
row = []
for cls in y:
    if cls not in row:
        row.append(cls)
row.sort()
print row

row_cm = []
for i in xrange(len(row)):
    Grade = ['A', 'B', 'C' , 'D' , 'F' , 'W' , 'S' , 'U' ,'na']
    grade = Grade[::-1][row[i]]
    print grade
    row_cm.append(grade)
print row_cm


[3, 4, 5, 6, 7, 8]
W
F
D
C
B
A
['W', 'F', 'D', 'C', 'B', 'A']

In [21]:
row_cm


Out[21]:
['W', 'F', 'D', 'C', 'B', 'A']

In [22]:
def plot_confusion_matrix(cm, title=subject, cmap=plt.cm.Blues):
   
    for y in range(cm.shape[0]):
        for x in range(cm.shape[1]):
            plt.text(x, y, '%.1f' % cm[y, x])
  
    plt.imshow(cm, interpolation='nearest', cmap=cmap)
    plt.title(title)
    plt.colorbar()
    tick_marks = np.arange(len(row_cm))
    plt.xticks(tick_marks, row_cm, rotation=45)
    plt.yticks(tick_marks, row_cm)
    plt.tight_layout()
    plt.ylabel('True label')
    plt.xlabel('Predicted label')
    
    
#     plt.pcolor(cm, cmap=cmap)
#     plt.yticks(np.arange(len(row_cm)),row_cm,label="#Training Data")
#     plt.xticks(np.arange(len(row_cm)),row_cm,label='#Class')
#     plt.colorbar()

In [34]:
# Compute confusion matrix
cm = confusion_matrix(y, y_pred)
np.set_printoptions(precision=2)
print('Confusion matrix')
print(row_cm)
print(cm)
plt.figure()
plot_confusion_matrix(cm)


Confusion matrix
['W', 'F', 'D', 'C', 'B', 'A']
[[ 24   2   6   0   0   0]
 [  0  90   9   1   0   0]
 [  1   3 171  18   2   0]
 [  1   2  17 273   2   2]
 [  0   0   4  12  78   1]
 [  0   0   0   2   3  41]]

In [35]:
cm


Out[35]:
array([[ 24,   2,   6,   0,   0,   0],
       [  0,  90,   9,   1,   0,   0],
       [  1,   3, 171,  18,   2,   0],
       [  1,   2,  17, 273,   2,   2],
       [  0,   0,   4,  12,  78,   1],
       [  0,   0,   0,   2,   3,  41]])

In [36]:
plt.show()

Confusion Matrix All Subjects

(has people enroll but no grade result)


In [237]:
for subject in subjects:
    #Create new Dataframe
    
    #print subject             
    df_sub = df_file[df_file['3COURSEID'] == subject]
    df_sub = df_sub.iloc[np.random.permutation(len(df_sub))]
    count_enrollment = df_sub['3COURSEID'].value_counts()
    #print "Number of %s enrollment: %s"%(subject,count_enrollment)

    A = df_sub.as_matrix()
    X = A[:,6:117]
    X = X.astype(np.int64, copy=False)
    y = A[:,2]
    y = y.astype(np.int64, copy=False)
    
    forest = RandomForestClassifier(n_estimators=10, max_depth=None, 
            min_samples_split=1, random_state=None, max_features=None)
    # Split the data into a training set and a test set
    X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.2,random_state=0)

    clf = forest.fit(X_train, y_train)
    y_pred = clf.predict(X_test)
    
    cm = confusion_matrix(y_test, y_pred)
    print('Confusion matrix of %s'%subject)
    print(cm)
    plt.figure()
    
    
    
    
#     # Split the data into a training set and a test set
#     X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.2,random_state=0)
    
#     forest = RandomForestClassifier(n_estimators=10, max_depth=None, 
#             min_samples_split=1, random_state=None, max_features=None)
#     clf = forest.fit(X_train, y_train)
#     y_pred = clf.predict(X_test)
    
#     cm = confusion_matrix(y_test, y_pred)
#     print('Confusion matrix of %s'%subject)
#     print(cm)
#     plt.figure()
    
    #plot_confusion_matrix(cm)


Confusion matrix of AT316
[[ 0  0  1  0]
 [ 0  0  1  0]
 [ 0  0 18  4]
 [ 0  0  3  2]]
Confusion matrix of AT326
[[ 0  1  0]
 [ 0 23  6]
 [ 0 12  3]]
Confusion matrix of BA291
[[0 0 0 1 0]
 [0 0 1 0 0]
 [0 0 0 4 0]
 [0 0 3 2 0]
 [0 0 1 0 0]]
Confusion matrix of CJ315
[[5 0]
 [1 0]]
Confusion matrix of CJ316
[[0 0 0]
 [1 4 1]
 [0 2 0]]
Confusion matrix of CJ317
[[0 0 0]
 [2 3 1]
 [0 2 0]]
Confusion matrix of CJ321
[[8 0]
 [1 0]]
Confusion matrix of CS101
[[ 0  0  0  1  0  0]
 [ 0  0  3 12  0  0]
 [ 0  1  2 30  0  0]
 [ 0  2 11 84  5  0]
 [ 0  0  1 31  0  0]
 [ 0  1  0  6  0  0]]
Confusion matrix of CS102
[[ 0  0  1  1  0  0]
 [ 0  0  0  9  2  1]
 [ 0  0  5 27  6  1]
 [ 1  0  9 56  9  4]
 [ 0  0  6 27  9  2]
 [ 0  0  1 14  2  1]]
Confusion matrix of CS105
[[ 0  0  8  2  1  0]
 [ 1  0  1  0  0  0]
 [ 1  0  7  1  3  0]
 [ 2  0 10  3  3  0]
 [ 1  0  9  2  1  0]
 [ 1  0  0  2  1  0]]
Confusion matrix of CS111
[[ 2  1  3  0  0  0]
 [ 3  8  7  5  0  0]
 [ 3 10 16 14  1  0]
 [ 3  5 14 30  6  3]
 [ 0  0  1 11  4  4]
 [ 0  1  0  4  3  5]]
Confusion matrix of CS115
[[0 0 0 0]
 [2 1 0 0]
 [1 0 0 0]
 [0 0 0 3]]
Confusion matrix of CS211
[[1 2 1 0 0 0]
 [0 2 5 0 0 0]
 [0 4 6 1 0 0]
 [0 0 1 1 0 1]
 [0 0 0 1 0 1]
 [0 0 0 0 0 0]]
Confusion matrix of CS213
[[ 3  4  2  1  0  0]
 [ 0  6  6  2  0  0]
 [ 1  4 19  9  0  0]
 [ 2  0 26 35  5  0]
 [ 0  0  3  9  4  1]
 [ 0  0  0  1  8  2]]
Confusion matrix of CS214
[[ 0  0  1  0  1]
 [ 0  0  0  1  0]
 [ 0  0  2 11  3]
 [ 0  0  7 29  9]
 [ 1  0  0 18 15]]
Confusion matrix of CS215
[[1 0 1 0 0]
 [1 0 1 0 0]
 [1 0 3 0 0]
 [0 0 2 1 0]
 [1 0 2 0 2]]
Confusion matrix of CS222
[[ 0  0  1  2  0  0]
 [ 1  1  0  2  0  0]
 [ 0  0  4  8  1  0]
 [ 2  0  6 38  5  1]
 [ 0  0  0 12  9  2]
 [ 0  0  0  0  2  1]]
Confusion matrix of CS223
[[ 0  0  1  1  0  0]
 [ 0  0  0  1  0  0]
 [ 0  0  3 11  2  0]
 [ 1  0 10 54  7  0]
 [ 0  0  1 21  9  0]
 [ 0  0  0  2  7  2]]
Confusion matrix of CS251
[[ 0  0  0  0  0  0]
 [ 1  0  0  1  0  0]
 [ 0  1  4 11  0  0]
 [ 0  0  5 45  1  1]
 [ 0  0  0  9  4  1]
 [ 0  0  0  2  5  4]]
Confusion matrix of CS261
[[ 1  0  1  1  0  0]
 [ 0  0  0  1  1  0]
 [ 1  0  6  3  0  0]
 [ 0  0  1 24 14  0]
 [ 0  0  0 14 24  4]
 [ 0  0  0  0  1  0]]
Confusion matrix of CS281
[[ 0  0  0  1  0  0]
 [ 0  0  1  0  0  0]
 [ 0  0  7 10  0  0]
 [ 0  0  3 40  9  0]
 [ 0  0  0  9 12  0]
 [ 0  0  0  0  2  0]]
Confusion matrix of CS284
[[ 0  0  0  1  0  0]
 [ 0  0  0  3  0  0]
 [ 0  0 11 15  0  0]
 [ 1  0  6 36 10  0]
 [ 0  0  4 21  4  2]
 [ 0  0  0  3  3  4]]
Confusion matrix of CS285
[[0 0 0 0]
 [0 1 0 0]
 [1 1 0 0]
 [0 0 0 2]]
Confusion matrix of CS286
[[0 1 0 0]
 [0 6 1 0]
 [0 1 1 1]
 [0 0 0 0]]
Confusion matrix of CS288
[[2 3 0 0]
 [1 7 2 0]
 [1 5 2 1]
 [0 1 1 2]]
Confusion matrix of CS289
[[ 0  0  1  0  0]
 [ 0  0  1  0  0]
 [ 0  1  1  4  0]
 [ 0  0  4 15  1]
 [ 0  0  1  7  1]]
Confusion matrix of CS295
[[0 0 0 0 1]
 [0 0 2 0 0]
 [0 2 1 0 0]
 [0 0 2 2 0]
 [0 0 4 1 0]]
Confusion matrix of CS296
[[0 0 0 0 1]
 [0 0 0 1 0]
 [0 0 1 3 0]
 [0 0 5 6 1]
 [0 0 1 2 2]]
Confusion matrix of CS297
[[1 0 0]
 [1 3 1]
 [2 1 2]]
Confusion matrix of CS300
[[3 4]
 [3 3]]
Confusion matrix of CS301
[[ 0  0  1  1]
 [ 0  7  6  2]
 [ 0  5 43  3]
 [ 0  1 11  5]]
Confusion matrix of CS302
[[ 0  0  1  0  0]
 [ 0  0  9  0  0]
 [ 0  1 21  7  1]
 [ 0  0  8 15  0]
 [ 0  0  0  3  2]]
Confusion matrix of CS311
[[ 0  1  0  0  0]
 [ 0  8  9  1  0]
 [ 0  9 22  1  0]
 [ 0  2  2  2  2]
 [ 0  0  5  2  3]]
Confusion matrix of CS314
[[ 2  0  3  6  1  0]
 [ 0  4  2  2  0  0]
 [ 1  2 14  8  0  0]
 [ 3  0 11 19  2  1]
 [ 1  0  3  8  3  1]
 [ 0  0  1  0  4  0]]
Confusion matrix of CS326
[[ 0  1  1  0]
 [ 0  2  0  0]
 [ 1  2 13  2]
 [ 1  0  5  1]]
Confusion matrix of CS341
[[ 4  6  0  0]
 [ 5 36  6  1]
 [ 1 11  7  2]
 [ 0  2  3  5]]
Confusion matrix of CS342
[[ 0  0  1  0  0]
 [ 0  1  3  0  0]
 [ 0  2 28  2  0]
 [ 0  0 16  9  2]
 [ 0  0  1  1  1]]
Confusion matrix of CS348
[[0 0 0 0 0]
 [1 0 0 0 0]
 [0 0 4 0 0]
 [0 0 0 0 0]
 [1 0 0 1 1]]
Confusion matrix of CS356
[[3 2]
 [4 1]]
Confusion matrix of CS365
[[ 0  0  0  2  0]
 [ 0  1  0  2  0]
 [ 0  0 14  2  0]
 [ 0  1  7  9  2]
 [ 0  0  1  6  1]]
Confusion matrix of CS366
[[1 2 0]
 [0 7 2]
 [0 2 1]]
Confusion matrix of CS367
[[0 0 1 0]
 [0 4 4 0]
 [1 1 2 1]
 [0 1 1 4]]
Confusion matrix of CS374
[[ 3  3  0  0]
 [ 2 15 12  0]
 [ 0 14 12  0]
 [ 0  0  6  1]]
Confusion matrix of CS377
[[0 2 0 0]
 [0 2 1 0]
 [0 0 4 0]
 [0 0 3 2]]
Confusion matrix of CS385
[[ 0  1  0  0]
 [ 0  5  3  0]
 [ 0  5 17  0]
 [ 0  2  4  0]]
Confusion matrix of CS386
[[0 0 1 0]
 [1 0 4 1]
 [0 3 3 1]
 [0 0 2 0]]
Confusion matrix of CS387
[[0 0 0 0]
 [1 1 3 1]
 [0 1 3 0]
 [0 1 0 0]]
Confusion matrix of CS388
[[0 1 0]
 [0 3 1]
 [0 0 2]]
Confusion matrix of CS395
[[ 0  0  0  2  0  0]
 [ 0  0  1  1  0  0]
 [ 0  0 13  6  0  0]
 [ 0  0  5 15  0  1]
 [ 0  0  0  3  2  1]
 [ 0  0  0  0  2  0]]
Confusion matrix of CS396
[[0 1 0 0 0]
 [0 0 0 0 0]
 [1 0 0 0 0]
 [0 1 0 3 2]
 [0 0 0 1 3]]
Confusion matrix of CS397
[[0 0 1 0]
 [0 1 1 0]
 [0 1 3 0]
 [0 1 1 0]]
Confusion matrix of CS398
[[4 0 0]
 [1 1 0]
 [2 0 0]]
Confusion matrix of CS399
[[2 0]
 [2 1]]
Confusion matrix of CS401
[[ 4 10]
 [10 43]]
Confusion matrix of CS402
[[ 1  0  0  0  1  0]
 [ 0  0  0  0  0  0]
 [ 0  0  0  0  3  0]
 [ 0  0  0  2  1  7]
 [ 0  0  0  1  0  7]
 [ 0  2  0  2  5 18]]
Confusion matrix of CS407
[[3 1]
 [1 2]]
Confusion matrix of CS408
[[0 1 0]
 [0 4 0]
 [0 1 0]]
Confusion matrix of CS409
[[0 0 1 0]
 [1 1 1 0]
 [0 0 7 1]
 [0 0 3 2]]
Confusion matrix of CS426
[[0 0 1 0]
 [0 0 2 0]
 [0 0 1 1]
 [0 0 0 1]]
Confusion matrix of CS427
[[0 0 1 1 0]
 [0 0 1 0 0]
 [0 0 0 3 0]
 [0 0 2 1 0]
 [0 0 0 3 0]]
Confusion matrix of CS429
[[1 3 0]
 [0 4 0]
 [0 3 0]]
Confusion matrix of CS446
[[4 0]
 [5 1]]
Confusion matrix of CS449
[[6]]
Confusion matrix of CS456
[[2 3 1]
 [1 2 1]
 [0 1 3]]
Confusion matrix of CS457
[[0 0 1 0]
 [0 0 3 0]
 [0 0 1 0]
 [0 0 0 2]]
Confusion matrix of CS459
[[1 1 0]
 [0 4 0]
 [0 2 2]]
Confusion matrix of CS467
[[0 1 0 0]
 [0 2 0 0]
 [0 4 3 1]
 [0 1 2 0]]
Confusion matrix of CS486
[[9 0 0]
 [5 0 0]
 [2 1 0]]
Confusion matrix of CS487
[[0 0 1 0 0]
 [0 0 1 2 0]
 [0 0 2 7 0]
 [0 0 6 7 1]
 [0 0 0 1 0]]
Confusion matrix of CS488
[[10  1]
 [ 7  4]]
Confusion matrix of CS489
[[0 0 1 0 0]
 [0 0 1 0 0]
 [0 1 3 5 0]
 [0 0 3 9 2]
 [0 0 0 1 0]]
Confusion matrix of EL070
[[ 0  4]
 [ 3 39]]
Confusion matrix of EL171
[[ 0  0  0  2  1  0]
 [ 0  0  1  1  1  1]
 [ 0  1 14 21  7  1]
 [ 0  0 19 25 17  0]
 [ 0  0  9 20  6  1]
 [ 0  0  0  3  1  0]]
Confusion matrix of EL172
[[ 0  1  0  2  1  0]
 [ 0  0  0  1  1  0]
 [ 0  0 10 13  2  0]
 [ 1  0 25 31 15  0]
 [ 0  0  4 11 12  1]
 [ 0  1  0  3  4  1]]
Confusion matrix of EL295
[[ 0  0  2  0  0  0]
 [ 0  0  1  0  0  0]
 [ 0  0  3  6  2  0]
 [ 0  0  3 40 11  1]
 [ 0  0  0 15 20  6]
 [ 0  0  0  0  2  6]]
Confusion matrix of EL395
[[ 0  1  0  0  0  0]
 [ 0  0  0  1  0  0]
 [ 0  0  5 10  1  1]
 [ 0  0  8 12  9  0]
 [ 0  0  3  4 14  8]
 [ 0  0  0  2  3  7]]
Confusion matrix of ES356
[[0 1 0 0]
 [0 0 0 0]
 [0 2 4 3]
 [0 0 2 0]]
Confusion matrix of HO201
[[ 0  0  1  1  0]
 [ 0  0  1  0  0]
 [ 0  0  1  2  0]
 [ 0  0  0 26  8]
 [ 0  0  0  8  4]]
Confusion matrix of HR201
[[5 3]
 [2 0]]
Confusion matrix of LA209
[[3 2 1 0]
 [1 0 0 0]
 [0 1 3 0]
 [0 2 0 1]]
Confusion matrix of MA211
[[57  2 12  4  1  0]
 [11  1  7  3  0  0]
 [15  2 15  7  3  1]
 [18  3 10  9  8  1]
 [ 2  1  3  3  5  0]
 [ 1  1  0  5  1  2]]
Confusion matrix of MA212
[[11  1  6  7  0  0]
 [ 2  0  1  0  0  0]
 [ 3  1  6  7  0  0]
 [ 7  0  6 17  7  0]
 [ 1  0  0  6  5  2]
 [ 1  0  2  1  2  6]]
Confusion matrix of MA216
[[2 0 2 1]
 [1 0 0 0]
 [0 0 1 0]
 [0 0 0 0]]
Confusion matrix of MA332
[[ 6  0  2  4  0  0]
 [ 1  0  0  1  0  0]
 [ 3  4 10 17  1  0]
 [ 5  0 13 17  5  0]
 [ 0  0  7  4  1  0]
 [ 0  0  0  0  1  0]]
Confusion matrix of MW313
[[3 3]
 [2 0]]
Confusion matrix of MW314
[[9 1]
 [1 1]]
Confusion matrix of NS132
[[0 1 0]
 [0 5 0]
 [0 3 0]]
Confusion matrix of PY228
[[ 0  0  0  3  0  0]
 [ 2  0  0  2  1  0]
 [ 1  0  3  7  3  2]
 [ 1  1  7 56  7  5]
 [ 0  0  2 11 11  2]
 [ 0  0  1  8  1  4]]
Confusion matrix of SC123
[[2 0 1 1 0 0]
 [1 0 1 0 0 0]
 [0 0 3 2 0 1]
 [0 1 5 3 0 0]
 [0 0 3 0 0 0]
 [0 0 1 0 0 0]]
Confusion matrix of SC135
[[ 3  9  3  8  1  0]
 [ 2  4  6  6  1  0]
 [ 7  2 13 11  2  1]
 [ 5  2 18 18  3  1]
 [ 2  1  3  6  3  0]
 [ 0  0  1  1  5  0]]
Confusion matrix of SC173
[[1 0 0 0 0 0]
 [0 0 0 1 0 0]
 [0 0 0 0 1 0]
 [3 0 0 8 0 0]
 [3 0 0 6 1 0]
 [0 0 0 0 1 0]]
Confusion matrix of SC185
[[ 1  1  1  7  0  0]
 [ 0  0  0  1  0  0]
 [ 2  1  2 11  0  0]
 [ 0  3 12 58  8  0]
 [ 0  1  0 23  4  1]
 [ 0  0  0  0  1  0]]
Confusion matrix of SO201
[[0 0 1 0 0]
 [0 1 0 0 0]
 [0 3 1 0 0]
 [0 1 1 0 0]
 [0 0 0 0 1]]
Confusion matrix of ST216
[[ 8  3  3  7  1  0]
 [ 0  0  6  2  0  0]
 [ 5  0 13  6  0  0]
 [ 6  1 12 13  4  0]
 [ 0  0  8  9  7  1]
 [ 1  0  0  5  3  1]]
Confusion matrix of SW111
[[0 0 0 1 0]
 [0 0 0 1 0]
 [0 0 2 4 0]
 [0 0 6 5 0]
 [0 0 0 2 0]]
Confusion matrix of SW212
[[ 0  0  0]
 [ 0  1  1]
 [ 1  2 12]]
Confusion matrix of SW213
[[0 0 1]
 [0 9 0]
 [0 3 0]]
Confusion matrix of SW221
[[ 0  0  0]
 [ 1 11  1]
 [ 0  3  1]]
Confusion matrix of SW335
[[1 0 0]
 [0 4 1]
 [0 1 3]]
Confusion matrix of SW365
[[ 0  0  1  0]
 [ 0  0  2  0]
 [ 0  1 11  0]
 [ 0  0  3  1]]
Confusion matrix of SW475
[[5 2]
 [2 3]]
Confusion matrix of SW478
[[0 1 0]
 [0 9 1]
 [0 2 0]]
Confusion matrix of TA395
[[0 0 0]
 [2 0 2]
 [0 3 2]]
Confusion matrix of TH161
[[ 0  0  0  0  2  1]
 [ 0  0  0  1  3  1]
 [ 0  0  0  0  6  0]
 [ 2  0  0  9 55  2]
 [ 1  1  0 20 68  1]
 [ 1  0  0  1  5  0]]
Confusion matrix of TU100
[[ 0  0  1  4  0]
 [ 0  0  0  1  0]
 [ 1  0  0  2  0]
 [ 0  0  1 18  6]
 [ 0  0  0  7  1]]
Confusion matrix of TU110
[[ 0  0  4  4  1  0]
 [ 0  1  2  0  0  0]
 [ 2  1 35 15  0  0]
 [ 1  0 29 23  4  0]
 [ 0  0  1  5  3  0]
 [ 0  0  1  1  1  0]]
Confusion matrix of TU120
[[ 0  1  0  0  0  1]
 [ 0  0  0  0  0  0]
 [ 0  0  2  8  7  2]
 [ 1  1  4 12 18  1]
 [ 1  2  8  8 37  6]
 [ 1  0  0  2  5  2]]
Confusion matrix of TU122
[[0 0 1 0 0]
 [2 6 2 0 0]
 [0 2 6 3 0]
 [1 0 1 4 0]
 [0 0 0 1 0]]
Confusion matrix of TU130
[[ 0  0  1  1  0]
 [ 0  2  7  0  0]
 [ 1  4 62  7  0]
 [ 1  0 17  8  1]
 [ 0  0  0  2  0]]
Confusion matrix of TU154
[[ 1  0  5 10  0  0]
 [ 0  0  6 18  0  0]
 [ 0  2 13 45  0  1]
 [ 6  2 15 39  1  2]
 [ 1  0  2 12  1  0]
 [ 0  0  1  7  0  0]]

In [ ]: