This repository has been archived by the owner on Aug 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_bar_graph.py
55 lines (42 loc) · 4.07 KB
/
make_bar_graph.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
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
j_tuning = {1: 0.9007314524555904, 2: 0.16488730723606168, 3: 0.7478632478632479, 4: 0.7241379310344828,
5: 0.6479591836734694, 6: 0.7018140589569161, 7: 0.5411954765751211, 8: 0.5960482985729967,
9: 0.8179723502304147, 10: 0.64, 11: 0.5888888888888889, 12: 0.04105263157894737,
13: 0.544973544973545, 14: 0.38310893512851896, 15: 0.4470899470899471, 16: 0.9343065693430657,
17: 0.44516129032258067, 18: 0.6888111888111889, 19: 0.383270911360799, 20: 0.7176196032672112,
21: 0.018867924528301886, 22: 0.05812220566318927, 23: 0.42902208201892744, 24: 0.48434237995824636,
25: 0.2929447852760736, 26: 0.3935643564356436, 27: 0.34309623430962344, 28: 0.48534583821805394,
29: 0.39707673568818513, 30: 0.10052910052910052, 31: 0.7072164948453609, 32: 0.5104438642297651,
33: 0.23717948717948717, 34: 0.8554216867469879, 35: 0.5881104033970276, 36: 0.193717277486911,
37: 0.4697855750487329, 38: 0.8977149075081611, 39: 0.6622369878183831, 40: 0.4121546961325967, 41: 0.7943722943722944}
p_tuning = {1: 0.9007314524555904, 2: 0.16844602609727166, 3: 0.7264957264957265, 4: 0.7192118226600985, 5: 0.6428571428571429, 6: 0.6689342403628118, 7: 0.5379644588045234, 8: 0.5916575192096597, 9: 0.7926267281105991, 10: 0.5577777777777778, 11: 0.5666666666666667, 12: 0.037894736842105266, 13: 0.5529100529100529, 14: 0.38555691554467564, 15: 0.46296296296296297, 16: 0.9259645464025026, 17: 0.4335483870967742, 18: 0.6958041958041958, 19: 0.36704119850187267, 20: 0.7187864644107351, 21: 0.018867924528301886, 22: 0.04918032786885246, 23: 0.4363827549947424, 24: 0.4812108559498956, 25: 0.28067484662576686, 26: 0.3774752475247525, 27: 0.34205020920502094, 28: 0.5005861664712778, 29: 0.37149817295980514, 30: 0.09523809523809523, 31: 0.7051546391752578, 32: 0.4856396866840731, 33: 0.2358974358974359, 34: 0.8524096385542169, 35: 0.583864118895966, 36: 0.18150087260034903, 37: 0.4327485380116959, 38: 0.8846572361262242, 39: 0.6522702104097453, 40: 0.41104972375690607, 41: 0.791125541125541}
without_control_token = {1: 0.8599791013584117, 2: 0.04863582443653618, 3: 0.6111111111111112, 4: 0.29064039408866993, 5: 0.6139455782312925, 6: 0.17346938775510204, 7: 0.39579967689822293, 8: 0.3106476399560922, 9: 0.45622119815668205, 10: 0.11888888888888889, 11: 0.2611111111111111, 12: 0.02631578947368421, 13: 0.30158730158730157, 14: 0.06487148102815178, 15: 0.3835978835978836, 16: 0.7038581856100105, 17: 0.3367741935483871, 18: 0.19230769230769232, 19: 0.19850187265917604, 20: 0.34072345390898484, 21: 0.0, 22: 0.026825633383010434, 23: 0.20399579390115669, 24: 0.060542797494780795, 25: 0.15184049079754602, 26: 0.2301980198019802, 27: 0.2405857740585774, 28: 0.1817116060961313, 29: 0.010962241169305725, 30: 0.010582010582010581, 31: 0.22268041237113403, 32: 0.4347258485639687, 33: 0.03333333333333333, 34: 0.8102409638554217, 35: 0.21443736730360935, 36: 0.027923211169284468, 37: 0.031189083820662766, 38: 0.6844396082698585, 39: 0.53156146179402, 40: 0.09613259668508287, 41: 0.3647186147186147}
j_list = j_tuning.values()
p_list = p_tuning.values()
w_list = without_control_token.values()
relation = p_tuning.keys()
# tuning = {"relation": relation, "j_tuning": j_list, "p_tuning": p_list}
diff = []
for i in range (41):
diff.append(list(j_list)[i] - list(w_list)[i])
tuning = {"relation": relation, "j_tuning": j_list, "without_control_token": w_list, "diff": diff}
tune = pd.DataFrame(tuning)
tune_least = tune.sort_values(by=['diff'], ascending=True).head(3)
tune_most = tune.sort_values(by=['diff'], ascending=False).head(3)
frames = [tune_most, tune_least]
result = pd.concat(frames)
w= 0.3
nrow = result.shape[0]
idx = np.arange(nrow)
plt.figure(figsize = (10, 5))
plt.xlabel('Relation num', fontsize=15)
plt.ylabel('Acc', fontsize=15)
plt.bar(idx - 0.5*w, result['without_control_token'], width=w, label ='W/O CT', color='#ADD8E6')
plt.bar(idx + 0.5*w, result['j_tuning'], width=w, label='W CT', color='#90EE90')
plt.xticks(idx, result['relation'])
plt.axvline(x=2.5, ymin=0, ymax=1,color='gray', ls='--')
plt.legend(ncol=nrow)
plt.tight_layout()
plt.savefig('graph_total')