<jupyter_start><jupyter_text>Using RASCOM - Anaconda prompt with the (base) environment,* Navigate to `D:\gal\ml-agents`* Launch unity hub  * Launch project `Project` using Unity `2018.4.17f1` * Navigate to `ML-Agents/Examples//Scenes/`*<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
plt.style.use('fivethirtyeight')
plt.style.use('dark_background')
plt.style.use('seaborn-bright')
def get_reward_data(file_path):
    df = pd.read_csv(file_path)
    df = df.dropna(axis=0)
    return df['Steps'], df['Policy/Extrinsic Reward']
# Comparing training times between PPO and SAC Policies.
# Get timing data from csvs
sac_times = pd.read_csv('sac_times1.csv',header=None)[2]
ppo_times = pd.read_csv('ppo_times.csv',header=None)[2]
ppo_3agents_times = pd.read_csv('time_3agents.csv',header=None)[2]
ppo_6agents_times = pd.read_csv('time_6agents.csv',header=None)[2]
ppo_9agents_times = pd.read_csv('time_9agents.csv',header=None)[2]
ppo_30agents_times = pd.read_csv('time_30agents.csv',header=None)[2]
df1_x, df1_y = get_reward_data('results/walker_T1/Walker.csv')
df4_x, df4_y = get_reward_data('results/walker_T4/Walker.csv')
df5_x, df5_y = get_reward_data('results/walker_T5/Walker.csv')
df6_x, df6_y = get_reward_data('results/walker_T6/Walker.csv')
df7_x, df7_y = get_reward_data('results/walker_T7/Walker.csv')
df8_x, df8_y = get_reward_data('results/walker_T8/Walker.csv')
df9_x, df9_y = get_reward_data('results/walker_T9/Walker.csv')
df10_x, df10_y = get_reward_data('results/walker_T10/Walker.csv')
df11_x, df11_y = get_reward_data('results/walker_T11/Walker.csv')
df12_x, df12_y = get_reward_data('results/walker_T12/Walker.csv')
df13_x, df13_y = get_reward_data('results/walker_T13/Walker.csv')
df14_x, df14_y = get_reward_data('results/walker_T14/Walker.csv')
df15_x, df15_y = get_reward_data('results/walker_T15/Walker.csv')
df16_x, df16_y = get_reward_data('results/walker_SAC1/Walker.csv')
df17_x, df17_y = get_reward_data('results/walker_3bois/Walker.csv')
df18_x, df18_y = get_reward_data('results/walker_6bois/Walker.csv')
df19_x, df19_y = get_reward_data('results/walker_9bois/Walker.csv')
df20_x, df20_y = get_reward_data('results/walker_30bois/Walker.csv')
df21_x, df21_y = get_reward_data('results/walker_30boi_long/Walker.csv')
df22_x, df22_y = get_reward_data('results/walker_lanky/Walker.csv')
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(df1_x.iloc[:669], df1_y.iloc[:669], label='default parameters')
axs.plot(df21_x.iloc[:200], df21_y.iloc[:200], label='tuned parameters')
axs.grid(False)
axs.legend(fontsize=20)
axs.set_xlabel('Step Number')
axs.set_ylabel('Policy Reward')
axs.set_title('Policy Reward vs Step for 2 Runs')
plt.savefig('reward_2runs_trunc.png')
plt.show()
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(df1_x, df1_y, label='default parameters')
axs.plot(df21_x, df21_y, label='tuned parameters')
axs.grid(False)
axs.legend(fontsize=20)
axs.set_xlabel('Step Number')
axs.set_ylabel('Policy Reward')
axs.set_title('Policy Reward vs Step for 2 Runs')
plt.savefig('reward_2runs.png')
plt.show()
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(df6_x, df6_y, label='1 layer')
axs.plot(df4_x, df4_y, label='2 layer')
axs.plot(df5_x, df5_y, label='3 layer')
axs.plot(df7_x, df7_y, label='4 layer')
axs.grid(False)
axs.legend(fontsize=15)
axs.set_xlabel('Step Number')
axs.set_ylabel('Policy Reward')
axs.set_title('Policy Reward Progression for Different Number of Hidden Layers')
plt.savefig('reward_layers.png')
plt.show()
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(df9_x, df9_y, label='learning_rate=0.03')
axs.plot(df10_x, df10_y, label='learning_rate=0.008')
axs.plot(df6_x, df6_y, label='learning_rate=0.003')
axs.plot(df8_x, df8_y, label='learning_rate=0.0003')
axs.grid(False)
axs.legend(fontsize=15)
axs.set_xlabel('Step Number')
axs.set_ylabel('Policy Reward')
axs.set_title('Policy Reward Progression for Different Learning Rates')
plt.savefig('reward_lr.png')
plt.show()
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(df6_x, df6_y, label='RNN=False')
axs.plot(df11_x, df11_y, label='RNN=True')
axs.grid(False)
axs.legend(fontsize=20)
axs.set_xlabel('Step Number')
axs.set_ylabel('Policy Reward')
axs.set_title('Policy Reward Progression Comparing Neural Network Types')
plt.savefig('reward_NN.png')
plt.show()
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(df11_x, df11_y, label='3000')
axs.plot(df12_x, df12_y, label='5000')
axs.plot(df13_x, df13_y, label='10000')
axs.plot(df14_x, df14_y, label='20000')
axs.grid(False)
axs.legend(fontsize=15)
axs.set_xlabel('Step Number')
axs.set_ylabel('Policy Reward')
axs.set_title('Policy Reward Progression for Different Summary Frequencies')
plt.savefig('reward_freq.png')
plt.show()
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(df15_x, df15_y, label='PPO')
axs.plot(df16_x, df16_y, label='SAC')
axs.grid(False)
axs.legend(fontsize=20)
axs.set_xlabel('Step Number')
axs.set_ylabel('Policy Reward')
axs.set_title('Policy Reward Progression for PPO and SAC Policies')
plt.savefig('reward_PPO_SAC.png')
plt.show()
print(sac_times.shape)
print(ppo_times.shape)
print(df15_y.shape)
# df15_x
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(df15_x, ppo_times, label='PPO Times (s)')
axs.plot(df15_x, sac_times, label='SAC Times (s)')
axs.grid(False)
axs.legend()
axs.set_xlabel('Step Number')
axs.set_ylabel('Total Training Time (s)')
axs.set_title('Training Time for PPO and SAC Policies')
plt.savefig('time_PPO_SAC.png')
plt.show()<jupyter_output><empty_output><jupyter_text>Make plot of y=reward vs x=training_timex_max should be 1250s<jupyter_code>ppo_times.max()
sac_times[:14]
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(ppo_times, df15_y, label='PPO')
axs.plot(sac_times, df16_y, label='SAC')
axs.grid(False)
axs.legend(fontsize=20)
axs.set_xlabel('Total Training Time (s)')
axs.set_ylabel('Policy Reward')
axs.set_title('Policy Reward vs Training Time for PPO and SAC Policies')
plt.savefig('reward_time.png')
plt.show()
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(ppo_times, df15_y, label='PPO')
axs.plot(sac_times[:14], df16_y[:14], label='SAC')
axs.grid(False)
axs.legend(fontsize=20)
axs.set_xlabel('Total Training Time (s)')
axs.set_ylabel('Policy Reward')
axs.set_title('Policy Reward vs Training Time for PPO and SAC Policies')
plt.savefig('reward_time_trunc.png')
plt.show()
fig, axs = plt.subplots(figsize=(12,10))
axs.plot(ppo_3agents_times, df17_y, label='3 agents')
axs.plot(ppo_6agents_times, df18_y, label='6 agents')
axs.plot(ppo_9agents_times, df19_y, label='9 agents')
axs.plot(ppo_30agents_times, df20_y, label='30 agents')
axs.grid(False)
axs.legend(fontsize=15)
axs.set_xlabel('Total Training Time (s)')
axs.set_ylabel('Policy Reward')
axs.set_title('Policy Reward vs Training Time for Different Number of Agents')
plt.savefig('reward_time_agents.png')
plt.show()
# env_name = "Builds/UnityEnvironment"  # Name of the Unity environment binary to launch
# train_mode = True  # Whether to run the environment in training or inference mode
# import matplotlib.pyplot as plt
# import numpy as np

# from unityagents import UnityEnvironment

# %matplotlib inline
# env = UnityEnvironment(file_name=env_name)

# # Examine environment parameters
# print(str(env))

# # Set the default brain to work with
# default_brain = env.brain_names[0]
# brain = env.brains[default_brain]
# from gym_unity.envs import UnityEnv
# import gym
# import numpy as np
# from stable_baselines.common.policies import MlpPolicy
# from stable_baselines.common.vec_env import DummyVecEnv
# from stable_baselines import PPO2
# from stable_baselines.bench import Monitor
# import os
# import time
# import pickle<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14734111543450065, 'fraction_numerical': 0.04448767833981842, 'mean_word_length': 7.596432552954292, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '619670', 'license': 'Apache-2.0', 'n_tokens_mistral': 3416, 'n_tokens_neox': 3151, 'n_words': 555, 'path': '.ipynb_checkpoints/ML_Unity-checkpoint.ipynb', 'repo_name': 'rasbot/9_to_5_Smash_It_AI', 'size': '7710'}