Author: Richard Möhn, <my first name>.moehn@posteo.de
%load_md se_abstract.md
%load_md se_intro.md
%load_md se_related.md
%load_md se_method.md
In [1]:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib
from matplotlib import pyplot as plt
import numpy as np
import numpy.ma as ma
import sys
sys.path.append("..")
from hiora_cartpole import interruptibility
import saveloaddata
import stats_experiments
import stats_experiments as se
In [2]:
data_dir_p = "../data"
%load_md se_results.md
In [11]:
plt.close('all')
In [13]:
algo = 'Sarsa'
fig, axes = se.arrange_algo_full()
clim, clim2 = se.load_plot_all(algo, '-rand-tiebreak', 1, axes, fig, data_dir_p)
se.load_plot_all(algo, '-rand-tiebreak', 0, axes, fig, data_dir_p, clim, clim2)
fig
Out[13]:
See Sarsa(λ) section above for an explanation of the plots.
In [8]:
algo = 'Q-learning'
fig, axes = se.arrange_algo_full()
clim, clim2 = se.load_plot_all(algo, '-drt', 1, axes, fig, data_dir_p)
se.load_plot_all(algo, '-drt', 0, axes, fig, data_dir_p, clim, clim2)
fig
Out[8]:
%load_md questions.md
%load_md se_ideas.md
%load_md se_bib.md
In [3]:
# Credits: https://nbviewer.jupyter.org/gist/HHammond/7a78d35b34d85406aa60
from IPython import paths
from IPython.core.display import HTML
import os
def css_styling():
"""Load default custom.css file from ipython profile"""
base = paths.get_ipython_dir()
styles = "<style>\n%s\n</style>" % (open('custom.css','r').read())
return HTML(styles)
css_styling()
Out[3]:
In [137]:
algo = 'Q-learning'
fig, ax = se.arrange_algo_full()
In [3]:
with saveloaddata.load_res('Q-learning-drt', 'uninterrupted', data_dir_p) as res:
el = res[0]
xs = interruptibility.rsxs2nparray(*res)
In [6]:
se.plot_episode_lengths(el[:10], ax.el[0])
In [21]:
se.plot_xs_hist(interruptibility.mask_after_cross(xs).flatten(), ax_comp[0])
In [33]:
before_cross = interruptibility.mask_after_cross(xs)
In [40]:
se.plot_xs_hist(before_cross.compressed(), ax_comp[0])
In [39]:
np.all(before_cross.compressed() <= 1.0)
Out[39]:
In [38]:
before_cross.compressed()
Out[38]:
In [31]:
se.plot_xs_hist(interruptibility.mask_after_cross(xs).flatten(), ax_comp[0], bins=25)
In [46]:
np.mean(before_cross.flatten()), np.mean(before_cross.compressed())
Out[46]:
In [64]:
del before_cross
In [4]:
with saveloaddata.load_res('Sarsa-rand-tiebreak', 'uninterrupted', data_dir_p) as res:
before_cross_unint = interruptibility.mask_after_cross(interruptibility.rsxs2nparray(*res))
In [129]:
mesh = se.plot_xss_cum_hist_devel(before_cross_int, ax.devel2[1], bins=2)
In [130]:
fig.colorbar(mesh, ax=ax.devel2[1])
Out[130]:
In [132]:
fig.colorbar(mesh, ax=ax.devel[1])
Out[132]:
In [131]:
mesh = se.plot_xss_cum_hist_devel(before_cross_int, ax.devel[1])
In [134]:
ax.devel[1].colorbar(mesh)
In [133]:
fig
Out[133]:
In [41]:
se.plot_xs_hist(interruptibility.mask_after_cross(xs).compressed(), ax, label='uninterrupted')
In [66]:
with saveloaddata.load_res('Sarsa-rand-tiebreak', 'interrupted', data_dir_p) as res:
before_cross_int = interruptibility.mask_after_cross(interruptibility.rsxs2nparray(*res))
In [42]:
se.plot_xs_hist(interruptibility.mask_after_cross(xs).compressed(), ax, label='interrupted')
In [ ]:
ax.legend()
In [43]:
fig
Out[43]:
In [193]:
stats_experiments.plot_mean_std_change(before_cross_unint, label='uninterrupted')
stats_experiments.plot_mean_std_change(before_cross_int, label='interrupted')
In [194]:
plt.legend()
plt.show()
In [174]:
se.plot_jsd_devel(before_cross_unint)
plt.show()
In [172]:
%debug
In [14]:
fig, ax = plt.subplots()
ax.set_xscale('log')
se.plot_jsd_comp_final(before_cross_unint, ax=ax)
In [9]:
ax.set_xlim([0.0, 0.03])
Out[9]:
In [15]:
ax.get_xlim()
Out[15]:
In [16]:
plt.show()
Interesting: Interruptions don't move the whole thing to the left, but limit variance.
In [52]:
fig, ax = plt.subplots()
mesh = stats_experiments.plot_xss_cum_hist_change(xs, ax, bins=25)
#plt.colorbar(mesh)
plt.show()
In [7]:
del xs
In [54]:
p = '../data/Sarsa-disc-uninterrupted-xe-170221003432.pickle'
with open(p, 'rb') as f:
res = pickle.load(f)
with open(p, 'wb') as f:
pickle.dump(res[0:2], f)
In [ ]: