File size: 2,264 Bytes
9c58361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

sns.set(font_scale =1, style='whitegrid', context='paper')
colors = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71", '#f1c40f']
palette = sns.color_palette(colors)

df 				= pd.read_csv('data/xiami.csv', sep='\t')
df['id'] 		= df.params

mtn         = df[df.algo == 'm2vTN'][['id','prec','rec', 'f1']]
mtn 		= pd.DataFrame(mtn.groupby(by='id').mean())
mtn['id'] 	= mtn.index

smtn 		= df[df.algo == 'sm2vTN'][['id','prec','rec', 'f1']]
smtn 		= pd.DataFrame(smtn.groupby(by='id').mean())
smtn['id'] 	= smtn.index

csmtn 	    = df[df.algo == 'csm2vTN'][['id','prec','rec', 'f1']]
csmtn 		= pd.DataFrame(csmtn.groupby(by='id').mean())
csmtn['id']	= csmtn.index

csmuk		= df[df.algo == 'csm2vUK'][['id','prec','rec', 'f1']]
csmuk 		= pd.DataFrame(csmuk.groupby(by='id').mean())
csmuk['id']	= csmuk.index

mtn.sort_index(ascending=False, inplace=True)
smtn.sort_index(ascending=False, inplace=True)
csmtn.sort_index(ascending=False, inplace=True)
csmuk.sort_index(ascending=False, inplace=True)

melt_mtn 	= pd.melt(mtn, id_vars='id')
melt_smtn 	= pd.melt(smtn, id_vars='id')
melt_csmtn 	= pd.melt(csmtn, id_vars='id')
melt_csmuk 	= pd.melt(csmuk, id_vars='id')

fig, axes = plt.subplots(2, 2, figsize=(25, 25))

a1 = sns.catplot(x='variable', y='value', hue='id', data=melt_mtn, kind='bar', palette=palette, ax=axes[0][0])
a2 = sns.catplot(x='variable', y='value', hue='id', data=melt_smtn, kind='bar', palette=palette, ax=axes[0][1])
a3 = sns.catplot(x='variable', y='value', hue='id', data=melt_csmtn, kind='bar', palette=palette, ax=axes[1][0])
a4 = sns.catplot(x='variable', y='value', hue='id', data=melt_csmuk, kind='bar', palette=palette, ax=axes[1][1])

plt.close(2)
plt.close(3)
plt.close(4)
plt.close(5)

titles = ['M-TN', 'SM-TN', 'CSM-TN', 'CSM-UK']

last = axes.flatten()[-1]
handles, labels = last.get_legend_handles_labels()
fig.legend(handles, labels, loc='upper left')

i=0
for ax in axes.flatten():
	ax.get_legend().remove()
	ax.set(yticks=np.arange(0, 0.21, 0.025))
	ax.set(xlabel='Metrics Used', ylabel='Valor')
	ax.set(title=titles[i])
	i+=1
	

plt.subplots_adjust(hspace=0.4)
fig.suptitle('Metrics', fontsize=18, y=.98)
plt.show()