|
--- |
|
tags: |
|
- Taxi-v3 |
|
- q-learning |
|
- reinforcement-learning |
|
- custom-implementation |
|
model-index: |
|
- name: q-Taxi-v3 |
|
results: |
|
- task: |
|
type: reinforcement-learning |
|
name: reinforcement-learning |
|
dataset: |
|
name: Taxi-v3 |
|
type: Taxi-v3 |
|
metrics: |
|
- type: mean_reward |
|
value: 7.56 +/- 2.71 |
|
name: mean_reward |
|
verified: false |
|
--- |
|
|
|
# **Q-Learning** Agent playing1 **Taxi-v3** |
|
This is a trained model of a **Q-Learning** agent playing **Taxi-v3** . |
|
|
|
## Usage |
|
```python |
|
import gymnasium as gym |
|
from huggingface_sb3 import load_from_hub |
|
import numpy as np |
|
import pickle |
|
|
|
# Load the model |
|
env_name = "Taxi-v3" |
|
model_name = "q-Taxi-v3" |
|
model_path = load_from_hub(repo_id="ch-bz/" + model_name, filename="q-learning.pkl") |
|
Qtable = pickle.load(open(model_path, "rb"))["qtable"] |
|
env = gym.make("Taxi-v3", render_mode="human") |
|
state, info = env.reset() |
|
|
|
while True: |
|
action = np.argmax(Qtable[state][:]) |
|
state, reward, terminated, truncated, info = env.step(action) |
|
env.render() |
|
|
|
if terminated or truncated: |
|
state, info = env.reset() |
|
``` |
|
|