-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfig4.py
77 lines (70 loc) · 2.74 KB
/
fig4.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
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
plt.style.use('seaborn-white')
from sys import argv
import os
import matplotlib as mlp
mlp.rcParams.update({'font.size': 14})
hue_order = ['MINE', 'fMINE', 'BCE']
model_names=['Ornstein–Uhlenbeck','Birth-Death','SIR','Lorenz attractor']
def plotit(obj):
ax = sns.violinplot(
x="sims", y=obj, hue="objective",
data=dfs_, palette="muted",cut=0, inner=None,edgecolor='white',linewidth=0.5,hue_order=hue_order)
handles = ax.legend_.legendHandles
labels = ['MINE', 'FDIV', 'BCE']
g=sns.swarmplot(data=dfs_, x="sims", y=obj, hue="objective",s=2,dodge=True,edgecolor='black',linewidth=0.5,hue_order=hue_order)
plt.legend(handles, labels,handlelength=1)
plt.ylabel(obj)
plt.xlabel('')
plt.ticklabel_format(axis="y", style="sci", scilimits=(0,0),useMathText=True)
left, right =plt.ylim()
plt.ylim([0,right+0.1*right])
letters=list('ABCDEFGHIJKLMNO')
plt.figure(figsize=(12,9),dpi=200)
models=['ou','bd','sir','lorentz']
l=0
for j,model in enumerate(models):
results=os.listdir('results/benchmarks/')
results=[e for e in results if model in e]
dfs_=[]
for i in [4,5,6]:
dfs=[]
r=[e for e in results if 'sim'+str(i) in e]
for e in r:
dfs.append(pd.read_csv('results/benchmarks/'+e))
dfs=pd.concat(dfs)
dfs['sims']=r'$10^{'+str(i)+'}$'
dfs_.append(dfs)
dfs_=pd.concat(dfs_)
ax=plt.subplot(3,4,1+j)
ax.annotate(letters[l], xy=(-0.1, 1.15), xycoords='axes fraction', textcoords='offset points', fontsize=15,xytext=(0, -5), weight='bold', ha='right', va='top')
l+=1
plt.title(model_names[j])
plotit('MI')
plt.ylabel('mutual information [bits]')
if model!='ou':
plt.ylabel('')
plt.legend([],[], frameon=False)
ax.spines['bottom'].set_position('zero')
ax=plt.subplot(3,4,5+j)
ax.annotate(letters[l], xy=(-0.1, 1.15), xycoords='axes fraction', textcoords='offset points', fontsize=15,xytext=(0, -5), weight='bold', ha='right', va='top')
l+=1
plotit('djs_scan')
plt.ylabel(r'$D_{JS}(Posteriors)$ [bits]')
if model!='ou': plt.ylabel('')
plt.legend([],[], frameon=False)
ax.spines['bottom'].set_position('zero')
ax=plt.subplot(3,4,9+j)
ax.annotate(letters[l], xy=(-0.1, 1.15), xycoords='axes fraction', textcoords='offset points', fontsize=15,xytext=(0, -5), weight='bold', ha='right', va='top')
l+=1
plotit('djs_mcmc_like')
plt.ylabel(r'$D_{JS}(Likelihoods)$ [bits]')
if model!='ou': plt.ylabel('')
plt.xlabel('N')
plt.legend([],[], frameon=False)
ax.spines['bottom'].set_position('zero')
plt.tight_layout(pad=1.1)
plt.savefig('results/plots/fig4.pdf')