Copyright 2019 DeepMind Technologies Limited.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


In [0]:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from google.colab import files
import io
import pandas as pd
import seaborn as sns

Plot parameters (edit as needed)


In [0]:
# Make a bar plot for average results from the final 100 episodes (True),
# or make a learning curve plot (False)
bar_plot = False

# Compare different penalties using the best beta value for each penalty (True),
# or compare different beta values for the same penalty (False):
compare_penalties = False

# If compare_penalties is False, specify the penalty parameters:
dev_measure = 'rel_reach'
dev_fun = 'truncation'
value_discount = 0.99

# Environment name
env_name = 'box'

# Filename suffix
suffix = ''

Plot settings


In [0]:
final_str = '_final' if bar_plot else ''
if compare_penalties:
  var = 'label'
  x_label = 'deviation_measure'
  legend_title = 'penalty'
  palette = sns.color_palette()
  filename = ('df_summary_penalties_' + env_name + final_str + suffix
              + '.csv')
else:
  var = 'beta'
  x_label = 'beta'
  legend_title = 'beta'
  palette = sns.cubehelix_palette()
  filename = ('df_summary_betas_' + env_name + '_' + dev_measure + '_' + dev_fun 
              + '_' + str(value_discount) + final_str + suffix + '.csv')

Load summary data output by results_summary.py


In [0]:
uploaded = files.upload()

In [0]:
df = pd.read_csv(io.BytesIO(uploaded[filename]))

Make bar plots


In [0]:
plot = sns.catplot(data=df, col='baseline', x=var, y='performance_smooth',
                   kind='bar', height=4, aspect=1.3)
axes = plot.axes.flatten()
for ax in axes:
  title = ax.get_title().split()
  ax.set_title(title[2] + ' baseline')
  ax.set_ylabel('performance')
  ax.set_xlabel(x_label)

Make learning curve plots


In [0]:
plot = sns.FacetGrid(df, col='baseline', size=5, aspect=1.3,
                     sharey=False, sharex=False)
plot.map_dataframe(sns.tsplot, time='episode', unit='seed', condition=var,
                   value='performance_smooth', n_boot=100, color=palette,
                   alpha=1.0, linewidth=1)
plot.add_legend(title=legend_title)
axes = plot.axes.flatten()
for ax in axes:
  title = ax.get_title().split()
  ax.set_title(title[2] + ' baseline')
  ax.set_ylabel('performance')
  ax.set_xlabel('episode')