<jupyter_start><jupyter_text>Comparing fitnesses<jupyter_code>#Hardcoded rules seems to give significantly higher fitnesses?
shy_fitness = pandas.read_csv(shy_rewards_file, names = ["Defensive"])
shy_fitness2 = pandas.read_csv(shy_rewards_file2, names = ["\nDefensive2"])
all_ones_fitness = pandas.read_csv(all_ones_reward_file, names = ["Aggressive"])


dynamic_manual_rules_fitnesses = pandas.read_csv(manual_obj_rewards_file, names = ["\nHardcoded"])
print(dynamic_manual_rules_fitnesses)

evolved_nn_fitnesses_frame = pandas.read_csv(evolved_objectives_file, names = ["Evolved"])
print(evolved_nn_fitnesses_frame)
import scipy.stats as st
print("Shy vs Dynamic: ", st.mannwhitneyu(shy_fitness, dynamic_manual_rules_fitnesses))
print("Shy vs Evolved: ", st.mannwhitneyu(shy_fitness, evolved_nn_fitnesses_frame))
print("Dynamic vs Evolved: ", st.mannwhitneyu(dynamic_manual_rules_fitnesses, evolved_nn_fitnesses_frame))
import matplotlib.pyplot as plt
sns.set(font_scale=1.5)
frames = [shy_fitness, shy_fitness2, all_ones_fitness, dynamic_manual_rules_fitnesses, evolved_nn_fitnesses_frame]
#print(evolved_nn_fitnesses_frame)
concatenated = pandas.concat(frames,sort=False)
plot=sns.boxplot(data=concatenated)
fig=plot.get_figure()
plt.ylabel("Fitness", fontsize=20)
fig.tight_layout()
fig.savefig('fitness_no_ammo.pdf', dpi=300)
#Shy has objective [1,1,-1]. Ones has objective [1,1,1].
#Evolved outperforms shy. That's interesting! It must have a different
#behavior, then? YES! A dynamic one!<jupyter_output><empty_output><jupyter_text>Analyzing behavior<jupyter_code>import numpy as np
behavior_file = "../"+EXPERIMENT_SUBFOLDER+"/nn_behavior_measures_to_objectives.csv"
behavior_frame = pandas.read_csv(behavior_file, sep=" ")
behavior_frame.shape
behavior_frame.rename(columns={"m_ammo": "Current Ammunition",
                              "m_health": "Current Health",
                              "m_frags": "Monsters Killed",
                              "o_ammo":"Ammunition",
                              "o_health":"Health",
                              "o_frags":"Attack"}, inplace=True)
print(behavior_frame)
#Removing all rows where ammo!=0, since we always have 0 ammo here.
behavior_frame=behavior_frame[behavior_frame["Current Ammunition"] == 0.0]
behavior_frame.shape
print(behavior_frame)
#Method for summarizing and plotting averages for 1 measurement.
def summarize_measurement_and_plot_objectives(dataframe, main_objective):
    meas_to_objectives_array = []
    unique_main_measures = dataframe[main_objective].unique()
    for unique_measure in unique_main_measures:
        #All frames with given value for the column
        sub_frame=dataframe.loc[dataframe[main_objective] == unique_measure]
        objective_means = [sub_frame["Ammunition"].mean(), sub_frame["Health"].mean(),sub_frame["Attack"].mean()]
        meas_to_objectives_array.append([unique_measure,*objective_means])

    meas_to_objectives_array=np.array(meas_to_objectives_array)
    df = pandas.DataFrame(meas_to_objectives_array, columns=[main_objective, 'Ammunition', 'Health', 'Attack'])
    ax=df.plot(x=main_objective, y=['Ammunition', 'Health', 'Attack'], linewidth=5)
    fig=ax.get_figure()
    plt.ylabel("Objective Weight", fontsize=20)
    fig.tight_layout()
    fig.savefig(main_objective.replace(" ","")+".pdf")

summarize_measurement_and_plot_objectives(behavior_frame, 'Current Health')
#We basically learned the very simple rule that we should always seek
#ammo+health, but if health gets really low, we should seek only health.
summarize_measurement_and_plot_objectives(behavior_frame, 'Current Ammunition')
summarize_measurement_and_plot_objectives(behavior_frame, 'Monsters Killed')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10959271168274384, 'fraction_numerical': 0.00669882100750268, 'mean_word_length': 6.096958174904943, 'pattern_counts': {'":': 6, '<': 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': '335468', 'license': 'MIT', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1227, 'n_words': 221, 'path': 'examples/EvolvingExperiment/notebooks/Analyze D3_battle_no_ammo.ipynb', 'repo_name': 'kaiolae/tf_future_prediction', 'size': '3732'}