Reinforcement Learning Fundamentals
Agents, environments, rewards and value functions: the MDP framework, bandits, and tabular methods like Q-learning.
Intermediate · about 10 hours · difficulty 3/5
Learn first: Probability for ML, Optimization and Gradient Descent
In reinforcement learning (RL) there are no labels. An agent takes actions in an environment, receives rewards, and must learn a policy that maximizes long-term reward. It is the framework behind game-playing agents, robotics control, and the preference tuning of language models.
The vocabulary
- Markov decision process (MDP): states, actions, transition probabilities, rewards and a discount factor gamma.
- Return: the discounted sum of future rewards.
- Value function V(s) and action-value function Q(s, a): how good a state or action is under a policy.
- Bellman equations express a value in terms of the next step's value; almost every algorithm is built on them.
Core ideas
- Exploration versus exploitation: try new actions or use the best known one. Multi-armed bandits isolate this trade-off and are used directly for A/B testing and ad selection.
- Dynamic programming (value and policy iteration) when the environment model is known.
- Monte Carlo and temporal-difference learning when it is not.
- Q-learning (off-policy) and SARSA (on-policy) learn Q-values from experience with epsilon-greedy exploration.
Tools
Gymnasium provides standard environments (CartPole, FrozenLake, MountainCar) with a common reset and step API. Start with tabular problems where you can print the whole Q-table and watch it converge.
Good enough to move on when you can implement tabular Q-learning for a grid world, tune epsilon and the learning rate, and explain the Bellman update you are applying.
Key concepts
- Agents, states, actions, rewards
- Markov decision processes
- Value functions and Bellman equations
- Exploration vs exploitation
- Multi-armed bandits
- Q-learning and SARSA
- Gymnasium environments
Mini project
Implement tabular Q-learning and SARSA for FrozenLake in Gymnasium, plot reward per episode for several epsilon schedules, and render the learned policy as arrows on the grid.
Check yourself
What is the difference between on-policy SARSA and off-policy Q-learning, and why does the discount factor matter?
Free resources
- Reinforcement Learning: An Introduction (Sutton and Barto) (Sutton and Barto)
- Gymnasium documentation (Farama Foundation)
- Hugging Face Learn (Hugging Face)