forked from remzawi/CS229-theme-classification
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualization.py
More file actions
41 lines (35 loc) · 1.42 KB
/
visualization.py
File metadata and controls
41 lines (35 loc) · 1.42 KB
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
import numpy as np
import seaborn as sn
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import normalize
data_arraycnn = np.load('confusion_matrix_cnn.npy')
print(data_arraycnn)
data_arraydnn = np.load('confusion_matrix_dense.npy')
print(data_arraydnn)
data_arrayNB = np.load('confusion_matrix_NB.npy')
print(data_arrayNB)
data_arraycnn = normalize(data_arraycnn, axis=1, norm='l1')
data_arraydnn = normalize(data_arraydnn, axis=1, norm='l1')
data_arrayNB = normalize(data_arrayNB, axis=1, norm='l1')
data_arraycnn = np.around(data_arraycnn, decimals=2)
data_arraydnn = np.around(data_arraydnn, decimals=2)
data_arrayNB = np.around(data_arrayNB, decimals=2)
df_cm = pd.DataFrame(data_arraycnn, index = [i for i in "ABCDEFGHIJKKMNOP"],
columns = [i for i in "ABCDEFGHIJKLMNOP"])
plt.figure(figsize = (10,7))
sn.heatmap(df_cm, annot=True)
plt.title('Confusion Matrix CNN')
plt.savefig('cfCNN.pdf')
df_cm = pd.DataFrame(data_arraydnn, index = [i for i in "ABCDEFGHIJKKMNOP"],
columns = [i for i in "ABCDEFGHIJKLMNOP"])
plt.figure(figsize = (10,7))
sn.heatmap(df_cm, annot=True)
plt.title('Confusion Matrix DNN')
plt.savefig('cfDNN.pdf')
df_cm = pd.DataFrame(data_arrayNB, index = [i for i in "ABCDEFGHIJKKMNOP"],
columns = [i for i in "ABCDEFGHIJKLMNOP"])
plt.figure(figsize = (10,7))
sn.heatmap(df_cm, annot=True)
plt.title('Confusion Matrix NB')
plt.savefig('cfNB.pdf')