In [1]:
import pandas as pd
from pandas.io.json import json_normalize #package for flattening json in pandas df
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import json
import os
%matplotlib inline

In [2]:
os.chdir("./runs/lagaris/1d_trapz_preparation/")
origin_path = os.getcwd() 
runs_id = os.listdir("./")
runs_id = [int(item) for item in runs_id]
runs_id = sorted(runs_id)

In [3]:
df_list = []
for run_id in runs_id:
    os.chdir("./"+str(run_id))
    f_in = open('out.json', 'r')
    run_info = json.load(f_in)
    f_in.close()
    a = json_normalize(run_info)
    #a.set_index(pd.Index([run_id]))
    df_list.append(a)
    #a = pd.concat(a,b)
    os.chdir(origin_path)
res1 = pd.concat(df_list,ignore_index=True)

In [4]:
res_correct = res1[res1['Model info.n_sig'] < 14]
#res_correct

In [9]:
res_n_sig5 = res_correct[res_correct['Model info.m_train'] == 16]

#m_train_all = np.array(res_n_sig5['Model info.m_train'].tolist())

#res_n_sig5 = res_correct
m_sig_all = np.array(res_n_sig5['Model info.n_sig'].tolist())


mse_all = np.array(res_n_sig5['Out info.MSE'].tolist())

mse_means = []
std_errs = []
h = 8

for i in range(13):
    ds = res_n_sig5[0+h*i:8+h*i]
    mse_l = np.array(ds['Out info.MSE'].tolist())
    mse_means.append(np.mean(mse_l))
    std_errs.append(np.std(mse_l))

my_set = set(m_sig_all)
m_sig = sorted( list(my_set) ) 
#print(m_sig)

figure = plt.figure(figsize=(12,8))
axes = figure.add_subplot (1, 1, 1)
plt.grid(True)
plt.title('MSE vs number of sigmoids', fontsize=15)
plt.xlabel('Number of sigmoids', fontsize=15)
plt.ylabel('MSE', fontsize=15)
plt.scatter(m_sig_all, mse_all, label = 'MSE for all points', marker = "D",s=40)

plt.plot(m_sig, mse_means, color='black', marker='x', linestyle='dashed', linewidth=3, markersize=16, label = 'Mean MSE')
plt.errorbar(m_sig, mse_means, yerr=std_errs, ecolor='r', lw=2, capsize=15, mew = 3, zorder=3, label = 'Std.error of MSE', linestyle='None')
axes.set_yscale ('log')#, nonposy='clip')

plt.legend(loc=2, prop={'size': 19})
#print(std_errs)


Out[9]:
<matplotlib.legend.Legend at 0x7f85bf725358>

In [ ]:
m_trains

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:
#%matplotlib notebook
n_sig_all = np.array(res_correct['Model info.n_sig'].tolist())
n_sig_all = n_sig_all.reshape(n_sig_all.size,1)

m_train_all = np.array(res_correct['Model info.m_train'].tolist())
m_train_all = m_train_all.reshape(m_train_all.size,1)

mse_all = np.array(res_correct['Out info.MSE'].tolist())
mse_all = mse_all.reshape(mse_all.size,1)


from mpl_toolkits.mplot3d.axes3d import Axes3D
fig = plt.figure(figsize=(15,10))
ax = fig.add_subplot(1, 2, 1, projection='3d')
ax.scatter(n_sig_all, m_train_all, np.log10(mse_all))

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:
plt.figure(figsize=(10,7))
plt.grid(True)
plt.title('MSE vs m_trapz', fontsize=15)
plt.xlabel('Number of integration points', fontsize=15)
plt.ylabel('MSE', fontsize=15)
ax = plt.gca()
res_correct.plot(
    x='Model info.n_sig',
    y='Out info.MSE',
    logy=True,
    #logx=True,
    ax = plt.gca(),
    style = 'ro',
)

ax.legend(
   loc='best',
   fontsize=15
)

In [ ]:
res2 = res_correct[res_correct['Model info.m_train'] > 35]
plt.figure(figsize=(10,7))
plt.title('MSE vs m_trapz', fontsize=26)
res2.plot.scatter(
    x='Model info.n_sig',
    y='Out info.MSE',
    logy=True,
    ax = plt.gca(),
)

In [ ]:
#1 6 11 16 21 26 31 36 41 46 51 56

In [ ]:
res_correct

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: