<jupyter_start><jupyter_text>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 athttps://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.<jupyter_code>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<jupyter_output><empty_output><jupyter_text>Plot parameters (edit as needed)<jupyter_code># 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 = ''<jupyter_output><empty_output><jupyter_text>Plot settings<jupyter_code>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')<jupyter_output><empty_output><jupyter_text>Load summary data output by results_summary.py<jupyter_code>uploaded = files.upload()
df = pd.read_csv(io.BytesIO(uploaded[filename]))<jupyter_output><empty_output><jupyter_text>Make bar plots<jupyter_code>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)<jupyter_output><empty_output><jupyter_text>Make learning curve plots<jupyter_code>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')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.105146124523507, 'fraction_numerical': 0.008894536213468869, 'mean_word_length': 5.090909090909091, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '261481', 'license': 'Apache-2.0', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1000, 'n_words': 270, 'path': 'side_effects_penalties/plot_results.ipynb', 'repo_name': 'BitForceStudio/deepmind-research', 'size': '3148'}