<jupyter_start><jupyter_text>Without noise<jupyter_code># For each row (eps,fraction), read the corresponding csv file and add the max reward to the log array
# TODO: replace max reward by mean max reward of different tentatives
for i in range (0,len(data),1):
    max_reward=[]
    step_to_max=[]
    for tentative in range(1,TENTATIVES+1,1):
        # Dir name is eps_fraction/tentative
        if data[i][2]==0:
            dir = str(data[i][0])+'_'+str(data[i][1])
        else :
            dir = str(data[i][0])+'_'+str(data[i][1])+'_noise'
        try:

            log2 = [l.split("\n")[0].split(",") for l in open(os.path.join('./log', dir, str(tentative),'progress.csv')).readlines()]
        except FileNotFoundError:
            print("not found")
        count = 0
        # Look for the index of mean 100 episodes reward
        for j in log2[0]:
            if j == 'mean 100 episode reward':
                index_reward = count
            if j == 'steps':
                index_steps = count
            count=count+1

        # Look for the max mean 100 episodes reward
        log2 = log2[1:]
        log2 = np.array(log2)
        mean_rew_100 = log2[:, index_reward].astype(np.float32)
        max_reward.append(np.max(mean_rew_100))
        step_to_max.append(log2[np.argmax(mean_rew_100),index_steps])
    max_reward=np.array(max_reward).astype(np.float32)
    step_to_max=np.array(step_to_max).astype(np.float32)
    data[i][3]=np.mean(max_reward)
    data[i][4]=np.std(max_reward)
    data[i][7]=np.median(step_to_max)

# For each eps, plot the evolution of reward according to fraction
plot(data,1,3,0,Filter={2:[0]})
plot(data,1,3,0,Filter={2:[1]})

plot(data,0,3,Filter={2:[0],1:[0.2]})
plot(data,0,3,1,Filter={2:[1]})

plot(data,0,3,2,Filter={1:[0.2,0.15]})
plot(data,1,3,2)<jupyter_output><empty_output><jupyter_text>With Noise<jupyter_code>TENTATIVE_NOISE=4


# For each row (eps,fraction), read the corresponding csv file and add the max reward to the log array
# TODO: replace max reward by mean max reward of different tentatives



# For each eps, plot the evolution of reward according to fraction
plt.figure()
plt.ylabel('Mean rew 100')
plt.xlabel('fraction')
plt.title('Mean max_reward - fraction with noise')
plt.axis([0, 0.35, 50, 200])
# TODO: iterate the values contained in csv instead of manual inputs
for eps in (0.01, 0.04, 0.07, 0.1, 0.15, 0.2, 0.25):
    fraction=[]
    mean=[]
    for i in range (0,len(log),1):
        if abs(log[i][0].astype(np.float32) - eps)<0.001:
            fraction.append(log[i][1].astype(np.float32))
            mean.append(log[i][4].astype(np.float32))
    xs, ys = zip(*sorted(zip(fraction, mean)))
    plt.plot(xs, ys, label='eps='+str(eps))
plt.legend(loc='best')
plt.savefig(os.path.join('./log', 'mean_max_reward_eps_noise.png'))
plt.show()
plt.close()



plt.figure()
plt.ylabel('Mean rew 100')
plt.xlabel('epsilon')
plt.title('Mean max_reward - final eps with noise')
plt.axis([0, 0.25, 50, 200])
# For each fraction, plot the evolution of reward according to eps
# TODO: iterate the values contained in csv instead of manual inputs
for fraction in (0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35):
    eps=[]
    mean=[]
    for i in range (0,len(log),1):
        if abs(log[i][1].astype(np.float32) - fraction)<0.001:
            eps.append(log[i][0].astype(np.float32))
            mean.append(log[i][4].astype(np.float32))

    xs, ys = zip(*sorted(zip(eps, mean)))
    plt.plot(xs, ys, label='fraction='+str(fraction))
plt.legend(loc='best')
plt.savefig(os.path.join('./log', 'mean_max_reward_fraction.png'))
plt.show()
plt.close()<jupyter_output><empty_output><jupyter_text>Comparaison of with/without noise<jupyter_code>eps_to_analyse=0.1
fraction_to_analyse=0.2

plt.figure()
plt.ylabel('Mean rew 100')
plt.xlabel('epsilon')
plt.title('Mean max_reward - final eps, fraction='+str(fraction_to_analyse))
plt.axis([0, 0.25, 50, 200])
# For each fraction, plot the evolution of reward according to eps
# TODO: iterate the values contained in csv instead of manual inputs
eps=[]
mean_with_noise=[]
mean_without_noise=[]
for i in range (0,len(log),1):
    if abs(log[i][1].astype(np.float32) - fraction_to_analyse)<0.001:
        eps.append(log[i][0].astype(np.float32))
        mean_with_noise.append(log[i][4].astype(np.float32))
        mean_without_noise.append(log[i][2].astype(np.float32))
xs, ys = zip(*sorted(zip(eps, mean_with_noise)))
xs_n, ys_n = zip(*sorted(zip(eps, mean_without_noise)))

plt.plot(xs, ys, label='with noise')
plt.plot(xs_n, ys_n, label='without noise')

plt.legend(loc='best')
plt.savefig(os.path.join('./log', 'comp_noise_fraction='+str(fraction_to_analyse)+'.png'))
plt.show()
plt.close()
plt.figure()
plt.ylabel('Mean rew 100')
plt.xlabel('epsilon')
plt.title('Mean max_reward - fraction, eps='+str(eps_to_analyse))
plt.axis([0.05, 0.25, 50, 200])
# For each fraction, plot the evolution of reward according to eps
# TODO: iterate the values contained in csv instead of manual inputs
fraction=[]
mean_with_noise=[]
mean_without_noise=[]
for i in range (0,len(log),1):
    if abs(log[i][0].astype(np.float32) - eps_to_analyse)<0.001:
        fraction.append(log[i][1].astype(np.float32))
        mean_with_noise.append(log[i][4].astype(np.float32))
        mean_without_noise.append(log[i][2].astype(np.float32))
xs, ys = zip(*sorted(zip(fraction, mean_with_noise)))
xs_n, ys_n = zip(*sorted(zip(fraction, mean_without_noise)))

plt.plot(xs, ys, label='with noise')
plt.plot(xs_n, ys_n, label='without noise')

plt.legend(loc='best')
plt.savefig(os.path.join('./log', 'comp_noise_eps='+str(eps_to_analyse)+'.png'))
plt.show()
plt.close()
tentative_to_analyse=3

filename='./log'
filename+='/'+str(eps_to_analyse)+'_'+str(fraction_to_analyse)
filename+='/'+str(tentative_to_analyse)
filename+='/progress.csv'
without_noise = [l.split("\n")[0].split(",") for l in open(filename).readlines()]
count=0
for i in without_noise[0]:
    if i == 'mean 100 episode reward':
        index_mean=count
    elif i=="steps":
        index_steps=count
    count=count+1
# print('index mean = ' + str(index_mean))
# print('index steps = ' + str(index_steps))
without_noise = without_noise[1:]  # ignore the first line which is a string comment
# colum order q_max,q_min,episodes,mean 100 episode reward,steps,% time spent exploring
without_noise = np.array(without_noise)
# print(len(log))
steps = without_noise[:, index_steps].astype(np.float32)
mean_rew_100 = without_noise[:, index_mean].astype(np.float32)

filename='./log'
filename+='/'+str(eps_to_analyse)+'_'+str(fraction_to_analyse)+'_noise'
filename+='/'+str(tentative_to_analyse)
filename+='/progress.csv'
with_noise = [l.split("\n")[0].split(",") for l in open(filename).readlines()]
count=0
for i in with_noise[0]:
    if i == 'mean 100 episode reward':
        index_mean=count
    elif i=="steps":
        index_steps=count
    count=count+1
# print('index mean = ' + str(index_mean))
# print('index steps = ' + str(index_steps))
with_noise = with_noise[1:]  # ignore the first line which is a string comment
# colum order q_max,q_min,episodes,mean 100 episode reward,steps,% time spent exploring
with_noise = np.array(with_noise)
# print(len(log))
steps_noise = with_noise[:, index_steps].astype(np.float32)
mean_rew_100_noise = with_noise[:, index_mean].astype(np.float32)

plt.figure()
plt.ylabel('Mean rew 100')
plt.xlabel('Steps')
plt.title('Individual run eps='+str(eps_to_analyse)+' fraction='+str(fraction_to_analyse))
plt.axis([0, np.max(steps), 0, np.max(mean_rew_100)])
plt.plot(steps, mean_rew_100,label='without noise')
plt.plot(steps_noise,mean_rew_100_noise,label='with noise')
plt.legend()
plt.show()
# plt.savefig(os.path.join(root, d, str(tentative),'Evolution mean reward - steps.png'))
plt.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16707238949391415, 'fraction_numerical': 0.03766816143497758, 'mean_word_length': 4.627974044700793, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '354846', 'license': 'MIT', 'n_tokens_mistral': 3180, 'n_tokens_neox': 2894, 'n_words': 600, 'path': 'baselines/deepq/plots.ipynb', 'repo_name': 'qifanz/baselines_GTL', 'size': '7805'}