-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot_results.py
More file actions
102 lines (79 loc) · 3.14 KB
/
plot_results.py
File metadata and controls
102 lines (79 loc) · 3.14 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
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 15 10:37:29 2018
@author: nikos
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
#read the data
df = pd.read_csv('comparison.csv')
#%% plot inject vs merge
# Notes on plotting:
# https://matplotlib.org/2.0.2/examples/api/barchart_demo.html
# https://stackoverflow.com/questions/22483588/how-can-i-plot-separate-pandas-dataframes-as-subplots
plt.close('all')
#create subplots
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(2*6,6))
#summarize scores per type (inject or merge)
pv = pd.pivot_table(df,values=['BLEU-1', 'BLEU-2', 'BLEU-3', 'BLEU-4'],
index = ['type'])
pv.plot(kind='bar',ax=axes[0])
plt.ylabel('BLEU score')
axes[0].set_title('inject vs merge: performance')
#summarize training time per type (inject or merge)
pv = pd.pivot_table(df,values=['train_time'],
index = ['type'])
pv=pv/pv.values.max()#normalize time
pv.plot(kind='bar',ax=axes[1])
plt.ylabel('relative training time')
axes[1].set_title('inject vs merge: total training time')
yticks=[0,1,pv.values[1][0]]
plt.yticks(yticks,[str(np.round(x*100,1))+'%' for x in yticks])
plt.axhline(pv.values[1],linestyle='--',color='k')
plt.savefig('./figures/compare_type.png',bbox_inches='tight')
#%% plot GRU vs LSTM
plt.close('all')
#create subplots
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(2*6,6))
#summarize scores per type (inject or merge)
pv = pd.pivot_table(df,values=['BLEU-1', 'BLEU-2', 'BLEU-3', 'BLEU-4'],
index = ['model'])
pv.sort_index(ascending=False,inplace=True)#to show LSTM, then GRU
pv.plot(kind='bar',ax=axes[0])
plt.ylabel('BLEU score')
axes[0].set_title('LSTM vs GRU: performance')
#summarize training time per type (inject or merge)
pv = pd.pivot_table(df,values=['train_time'],
index = ['model'])
pv.sort_index(ascending=False,inplace=True)#to show LSTM, then GRU
pv=pv/pv.values.max()#normalize time
pv.plot(kind='bar',ax=axes[1])
plt.ylabel('relative training time')
axes[1].set_title('LSTM vs GRU: total training time')
yticks=[0,1,pv.values[1][0]]
plt.yticks(yticks,[str(np.round(x*100,1))+'%' for x in yticks])
plt.axhline(pv.values[1],linestyle='--',color='k')
plt.savefig('./figures/compare_model.png',bbox_inches='tight')
#%% for merge GRU plot dropout
plt.close('all')
#create subplots
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(2*6,6))
#summarize scores per type (inject or merge)
pv = pd.pivot_table(df,values=['BLEU-1', 'BLEU-2', 'BLEU-3', 'BLEU-4'],
index = ['dropout'])
pv.plot(kind='bar',ax=axes[0])
plt.ylabel('BLEU score')
axes[0].set_title('merge GRU: performance')
#summarize training time per type (inject or merge)
pv = pd.pivot_table(df,values=['train_time'],
index = ['dropout'])
pv=pv/pv.values.max()#normalize time
pv.plot(kind='bar',ax=axes[1])
plt.ylabel('relative training time')
axes[1].set_title('merge GRU: total training time')
yticks=[0,1,pv.values[0][0]]
plt.yticks(yticks,[str(np.round(x*100,1))+'%' for x in yticks])
plt.axhline(pv.values[0],linestyle='--',color='k')
plt.savefig('./figures/merge_GRU_dropout.png',bbox_inches='tight')