forked from JuneQiong/PESI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplt_hot.py
115 lines (102 loc) · 5.5 KB
/
plt_hot.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
import pdb
import random
import numpy
from matplotlib import pyplot as plt
from matplotlib import colors
from decimal import Decimal
import pickle
from matplotlib import cm
from matplotlib import axes
from sklearn import preprocessing
def draw():
xLabel = ['UI', '<bos>', 'the', 'hotel', 'is', 'very', 'nice', 'and', 'the', 'staff', 'are', 'very', 'friendly']
yLabel = ['UI', 'the', 'hotel', 'is', 'very', 'nice', 'and', 'the', 'staff', 'are', 'very', 'friendly', '<eos>']
# data of orign model
# data =[[1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
# 0.0000, 0.0000, 0.0000, 0.0000],
# [0.4857, 0.5143, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
# 0.0000, 0.0000, 0.0000, 0.0000],
# [0.3456, 0.3056, 0.3488, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
# 0.0000, 0.0000, 0.0000, 0.0000],
# [0.3034, 0.2434, 0.2222, 0.2310, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
# 0.0000, 0.0000, 0.0000, 0.0000],
# [0.2684, 0.1875, 0.1573, 0.2377, 0.1491, 0.0000, 0.0000, 0.0000, 0.0000,
# 0.0000, 0.0000, 0.0000, 0.0000],
# [0.2679, 0.1542, 0.1093, 0.1763, 0.1327, 0.1596, 0.0000, 0.0000, 0.0000,
# 0.0000, 0.0000, 0.0000, 0.0000],
# [0.1788, 0.1590, 0.1102, 0.1699, 0.0976, 0.1531, 0.1315, 0.0000, 0.0000,
# 0.0000, 0.0000, 0.0000, 0.0000],
# [0.1714, 0.1247, 0.0893, 0.1338, 0.0896, 0.1195, 0.1352, 0.1366, 0.0000,
# 0.0000, 0.0000, 0.0000, 0.0000],
# [0.1687, 0.1083, 0.0800, 0.1214, 0.0768, 0.0975, 0.1166, 0.1263, 0.1044,
# 0.0000, 0.0000, 0.0000, 0.0000],
# [0.1679, 0.0958, 0.0746, 0.1132, 0.0697, 0.0819, 0.1044, 0.1144, 0.0980,
# 0.0800, 0.0000, 0.0000, 0.0000],
# [0.1743, 0.0802, 0.0667, 0.1020, 0.0619, 0.0707, 0.0889, 0.0964, 0.0861,
# 0.0757, 0.0972, 0.0000, 0.0000],
# [0.1702, 0.0688, 0.0623, 0.0921, 0.0560, 0.0608, 0.0763, 0.0761, 0.0730,
# 0.0674, 0.0852, 0.1118, 0.0000],
# [0.1669, 0.0648, 0.0593, 0.0873, 0.0511, 0.0546, 0.0682, 0.0690, 0.0670,
# 0.0635, 0.0783, 0.1058, 0.0642]]
# data of xiaorong
data = [[1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000],
[0.5626, 0.4374, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000],
[0.5364, 0.1920, 0.2716, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000],
[0.3364, 0.1106, 0.2331, 0.3199, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000],
[0.2276, 0.0779, 0.1823, 0.3915, 0.1208, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000],
[0.2154, 0.0528, 0.1180, 0.3143, 0.1774, 0.1221, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000],
[0.1613, 0.0361, 0.0762, 0.2543, 0.1745, 0.1665, 0.1311, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000],
[0.2327, 0.1467, 0.0633, 0.0678, 0.0814, 0.0758, 0.0669, 0.2654, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000],
[0.2144, 0.1167, 0.0502, 0.0523, 0.0641, 0.0567, 0.0488, 0.1894, 0.2074,
0.0000, 0.0000, 0.0000, 0.0000],
[0.1937, 0.0970, 0.0393, 0.0426, 0.0477, 0.0410, 0.0360, 0.1419, 0.1654,
0.1953, 0.0000, 0.0000, 0.0000],
[0.1694, 0.0825, 0.0295, 0.0346, 0.0330, 0.0286, 0.0268, 0.1137, 0.1298,
0.1622, 0.1899, 0.0000, 0.0000],
[0.1361, 0.0696, 0.0209, 0.0270, 0.0213, 0.0192, 0.0203, 0.0992, 0.1098,
0.1337, 0.1660, 0.1769, 0.0000],
[0.0183, 0.0048, 0.0125, 0.0107, 0.0104, 0.0032, 0.0063, 0.0931, 0.1226,
0.1584, 0.2214, 0.3053, 0.0330]]
# '#fff0b3', '#ffeb99'
# cmap = colors.ListedColormap(['#fff5cc', '#ffe066', '#ffd633', '#ffcc00', '#e6b800', '#cca300', '#997a00', '#4d3d00'])
# bounds = [-0.5, 0.5, 1.5, 2.5, 3.5]
# norm = colors.BoundaryNorm(bounds, cmap.N)
# heatmap = plt.pcolor(data, cmap=cmap)
# plt.colorbar(heatmap, ticks=[0, 1, 2, 3])
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_yticks(range(len(yLabel)))
ax.set_yticklabels(yLabel)
ax.set_xticks(range(len(xLabel)))
ax.set_xticklabels(xLabel)
im = ax.imshow(data, cmap=plt.cm.Blues) # cmap=cmap
cb = plt.colorbar(im)
# cb.set_label('The columnwise percentage of sentiment polarity ', fontsize=20)
# cb.set_ticks([0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5])
cb.set_ticks([0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1])
plt.tight_layout()
plt.title("The User 10 of TripAdvisor Dataset", fontsize=24)
plt.tick_params(labelsize=16)
# show
plt.xlabel("Inputs", fontsize=18)
# plt.xticks(rotation=45)
plt.ylabel("Outputs", fontsize=18)
# data_list = data.tolist()
# for i in range(3):
# for j in range(3):
# if (i==0 and j==0) or (i==2 and j==2) :
# text = plt.text(j, i, Decimal(data_list[i][j]).quantize(Decimal("0.0000")),
# ha="center", va="center", color='white', fontsize=26)
# else:
# text = plt.text(j, i, Decimal(data_list[i][j]).quantize(Decimal("0.0000")),
# ha="center", va="center", color='black', fontsize=26)
plt.show()
draw()