<jupyter_start><jupyter_text>Results Episode 20000/20000 || exploration_rate 5e-05 || Best average reward 8.76rage reward 8.766 Episode Ended  alpha (0.1) || gamma (0.5) || best_avg_reward (8.76)Episode 20000/20000 || exploration_rate 5e-05 || Best average reward 8.79rage reward 8.799 Episode Ended  alpha (0.1) || gamma (0.9) || best_avg_reward (8.79)Episode 20000/20000 || exploration_rate 5e-05 || Best average reward 8.92rage reward 8.922 Episode Ended  alpha (0.1) || gamma (1) || best_avg_reward (8.92)Episode 20000/20000 || exploration_rate 5e-05 || Best average reward 8.48rage reward 8.4883 Episode Ended  alpha (0.05) || gamma (0.5) || best_avg_reward (8.48)Episode 20000/20000 || exploration_rate 5e-05 || Best average reward 8.71rage reward 8.711 Episode Ended  alpha (0.05) || gamma (0.9) || best_avg_reward (8.71)Episode 20000/20000 || exploration_rate 5e-05 || Best average reward 8.92rage reward 8.922 Episode Ended  alpha (0.05) || gamma (1) || best_avg_reward (8.92)Episode 20000/20000 || exploration_rate 5e-05 || Best average reward 0.51rage reward 0.51185 Episode Ended  alpha (0.01) || gamma (0.5) || best_avg_reward (0.51)Episode 20000/20000 || exploration_rate 5e-05 || Best average reward 8.21rage reward 8.21133 Episode Ended  alpha (0.01) || gamma (0.9) || best_avg_reward (8.21)Episode 20000/20000 || exploration_rate 5e-05 || Best average reward 8.57rage reward 8.57713 Episode Ended  alpha (0.01) || gamma (1) || best_avg_reward (8.57)<jupyter_code>#from agent import Agent
#from monitor import interact
from bayes_opt import BayesianOptimization

import gym
import numpy as np

env = gym.make('Taxi-v3')
agent = Agent()


def taxi_best_params(alpha, gamma):
    agent = Agent(alpha=alpha, gamma=gamma)
    avg_rewards, best_avg_reward = interact(env, agent, num_episodes)
    return best_avg_reward


optimizer = BayesianOptimization(
    taxi_best_params,
    { 
        'alpha': (0.1, 0.05, 0.01), 
        'gamma': (0.5, 0.9, 1)
    }
)


optimizer.maximize(3, 2)

print("The optimizer params : {0}".format(optimizer.max['params']))
print("The optimaizer result: {0}".format(optimizer.max['target']))<jupyter_output>|   iter    |  target   |   alpha   |   gamma   |
-------------------------------------------------
{'fraction_non_alphanumeric': 0.14933333333333335, 'fraction_numerical': 0.12044444444444445, 'mean_word_length': 3.882863340563991, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '239851', 'license': 'MIT', 'n_tokens_mistral': 953, 'n_tokens_neox': 783, 'n_words': 214, 'path': 'lab-taxi/Taxi-v2.ipynb', 'repo_name': 'prp1679/Udacity-Deep-Learning-NanoDegree', 'size': '2250'}