<jupyter_start><jupyter_text>Plotting Tools<jupyter_code>import os
import csv
import glob

import numpy as np
from scipy.io import loadmat, savemat
import matplotlib.pyplot as plt
def plot_one_run(log_dir):
    all_returns = []
    for log_file in sorted(glob.glob(log_dir + "logs.mat")):
        data = loadmat(log_file)
        all_returns.append(data["returns"][0])

    max_trial_length = min(map(len, all_returns))
    trimmed_returns = np.array([r[:max_trial_length] for r in all_returns])
    average_returns = np.mean(trimmed_returns, axis=0)
    # Plot result
    plt.figure()
    plt.plot(np.arange(len(average_returns)), average_returns)
    plt.title("Returns vs Iteration (averaged across seeds)")
    plt.xlabel("Iteration number")
    plt.ylabel("Return")
    plt.show()<jupyter_output><empty_output><jupyter_text>Cartpole<jupyter_code>plot_one_run('/home/vitchyr/git/handful-of-trials/log/test/2019-07-01--16:18:38/')https://www.youtube.com/watch?v=uj6Z7ZYuSzs&list=PLsbYZauRyT1KZvMjDMNm-3NheCXzwLZub&index=14<jupyter_output><empty_output><jupyter_text>Pointmass  Pointmass Fixed Goal With squared exponential loss, it solves it perfectly<jupyter_code>plot_one_run('/home/vitchyr/git/handful-of-trials/log/pointmass-reach-fixed-point-cartpole-settings/2019-07-01--17:22:52/')<jupyter_output><empty_output><jupyter_text>With squared loss:<jupyter_code>plot_one_run('/home/vitchyr/git/handful-of-trials/log/pointmass-reach-fixed-point-cartpole-settings-squared-loss/2019-07-01--17:28:09/')<jupyter_output><empty_output><jupyter_text>Pointmass: No Walls (Varied goals)<jupyter_code>plot_one_run('/home/vitchyr/git/handful-of-trials/log/pointmass-no-walls-cartpole-settings-squared-loss/2019-07-01--21:03:37/')<jupyter_output><empty_output><jupyter_text>Pointmass U Wall<jupyter_code>plot_one_run('/home/vitchyr/git/handful-of-trials/log/pointmass-u-wall-solve-in-8-ph10-run2/2019-07-01--22:41:41/')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1432251416795466, 'fraction_numerical': 0.0422462648119526, 'mean_word_length': 6.273408239700374, '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': '454573', 'license': 'MIT', 'n_tokens_mistral': 827, 'n_tokens_neox': 762, 'n_words': 77, 'path': 'plotter.ipynb', 'repo_name': 'vitchyr/handful-of-trials', 'size': '1941'}