Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language: en
|
| 4 |
+
datasets:
|
| 5 |
+
- gymnasium
|
| 6 |
+
metrics:
|
| 7 |
+
- episode_reward
|
| 8 |
+
pipeline_tag: reinforcement-learning
|
| 9 |
+
tags:
|
| 10 |
+
- reinforcement-learning
|
| 11 |
+
- q-learning
|
| 12 |
+
- tabular-rl
|
| 13 |
+
- gymnasium
|
| 14 |
+
- frozenlake
|
| 15 |
+
library_name: numpy
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Q-Learning Agent — FrozenLake-v1
|
| 19 |
+
|
| 20 |
+
This repository contains a trained **Q-Learning agent** for the Gymnasium environment **FrozenLake-v1**.
|
| 21 |
+
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
## Environment
|
| 25 |
+
|
| 26 |
+
- **Environment:** FrozenLake-v1
|
| 27 |
+
- **State Space:** 16 discrete states
|
| 28 |
+
- **Action Space:** 4 discrete actions
|
| 29 |
+
- **Type:** Stochastic grid-world (slippery surface)
|
| 30 |
+
|
| 31 |
+
FrozenLake is a small Markov Decision Process (MDP) where the agent must reach a goal while avoiding holes.
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
+
|
| 35 |
+
## Algorithm
|
| 36 |
+
|
| 37 |
+
This model uses **Tabular Q-Learning**, a model-free off-policy reinforcement learning algorithm.
|
| 38 |
+
|
| 39 |
+
Update rule:
|
| 40 |
+
|
| 41 |
+
Q(s,a) ← Q(s,a) + α [ r + γ max_a' Q(s',a') − Q(s,a) ]
|
| 42 |
+
|
| 43 |
+
Where:
|
| 44 |
+
- α = learning rate
|
| 45 |
+
- γ = discount factor
|
| 46 |
+
|
| 47 |
+
Because the environment is discrete and small, Q-values are stored in a Q-table of shape (16 × 4).
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## Training Details
|
| 52 |
+
|
| 53 |
+
- Learning rate (α): 0.1
|
| 54 |
+
- Discount factor (γ): 0.99
|
| 55 |
+
- Episodes: 5000
|
| 56 |
+
- Epsilon-greedy exploration with decay
|
| 57 |
+
|
| 58 |
+
The agent learns to maximize expected long-term reward despite stochastic transitions.
|
| 59 |
+
|
| 60 |
+
---
|
| 61 |
+
|
| 62 |
+
## Performance
|
| 63 |
+
|
| 64 |
+
Training reward was tracked across episodes.
|
| 65 |
+
|
| 66 |
+
The agent successfully learns an optimal navigation policy to reach the goal.
|
| 67 |
+
|
| 68 |
+
---
|
| 69 |
+
|
| 70 |
+
## Visualization
|
| 71 |
+
|
| 72 |
+
Below is the trained agent interacting with the environment:
|
| 73 |
+
|
| 74 |
+

|
| 75 |
+
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
## Files
|
| 79 |
+
|
| 80 |
+
- `frozenlake_q_table.npy` → Trained Q-table
|
| 81 |
+
- `frozenlake_trained_agent.gif` → Agent demonstration
|
| 82 |
+
|
| 83 |
+
---
|
| 84 |
+
|
| 85 |
+
## Summary
|
| 86 |
+
|
| 87 |
+
This project demonstrates:
|
| 88 |
+
|
| 89 |
+
- Tabular reinforcement learning
|
| 90 |
+
- Bellman optimality updates
|
| 91 |
+
- Exploration vs exploitation trade-off
|
| 92 |
+
- Convergence in finite MDPs
|
| 93 |
+
|
| 94 |
+
It serves as a foundational reinforcement learning example.
|