ML Notes
Introduction to reinforcement learning concepts including agents, environments, rewards, policies, and value functions with Python examples.
Reinforcement Learning (RL) is the third pillar of machine learning where an agent learns to make decisions by interacting with an environment. Unlike supervised learning, there are no correct answer labels — the agent receives reward signals that indicate how good its actions were.
The RL Framework
| ──────────────────► | ||||
|---|---|---|---|---|
| Agent | Environment | |||
| ◄────────────────── |
Key Concepts
| Concept | Definition | Example (Chess) |
|---|---|---|
| Agent | The learner/decision maker | The chess player |
| Environment | What the agent interacts with | The chess board |
| State | Current situation | Board position |
| Action | What the agent can do | Move a piece |
| Reward | Feedback signal | +1 win, -1 loss, 0 draw |
| Policy | Strategy (state → action mapping) | Playing style |
| Value | Expected future reward from a state | Position evaluation |
Markov Decision Process (MDP)
RL problems are formalized as MDPs with the Markov property: the future depends only on the current state, not on how you got there.
Q-Learning Algorithm
Q-Learning learns the value of each state-action pair without needing a model of the environment:
Exploration vs Exploitation
| │ Exploitation | Do what you know works best │ |
| │ | May miss better options │ |
| │ Exploration | Try new things │ |
| │ | May waste time on bad options │ |
| │ Solution | ε-greedy, UCB, Thompson Sampling │ |
Comparison: RL vs Supervised vs Unsupervised
| Aspect | Supervised | Unsupervised | RL |
|---|---|---|---|
| Feedback | Immediate correct label | None | Delayed reward |
| Data | Static dataset | Static dataset | Sequential interactions |
| Goal | Minimize prediction error | Find structure | Maximize cumulative reward |
| Challenges | Overfitting, bias | Evaluation | Exploration, credit assignment |
Real-World RL Applications
- Gaming: AlphaGo, Atari game agents, Dota 2
- Robotics: Robot grasping, locomotion, manipulation
- Finance: Portfolio optimization, order execution
- Healthcare: Treatment optimization, drug dosing
- Recommendations: Content sequencing, ad placement
- Autonomous driving: Lane changing, intersection handling
Interview Questions
- What is the exploration-exploitation tradeoff?
Exploitation uses current knowledge to maximize immediate reward. Exploration tries new actions to potentially discover better strategies. Balance is needed — too much exploitation gets stuck in local optima, too much exploration wastes time.
- What is the difference between model-based and model-free RL?
Model-based RL learns a model of the environment (transition probabilities) and plans ahead. Model-free RL (Q-learning, policy gradient) learns directly from experience without modeling the environment.
- Why is credit assignment a challenge in RL?
When a reward arrives after many actions, it's hard to determine which past actions contributed to that reward. Was it move 5 or move 50 that led to winning the game?
- What is the difference between on-policy and off-policy learning?
On-policy (SARSA) learns about the policy it's currently following. Off-policy (Q-learning) learns about the optimal policy while following a different exploration policy.
- When would you NOT use reinforcement learning?
When you have plenty of labeled data (use supervised learning instead), when the environment is too expensive to simulate, or when there's no clear reward signal to optimize.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Reinforcement Learning Fundamentals — Machine Learning.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Machine Learning topic.
Search Terms
machine-learning, machine learning, machine, learning, fundamentals, reinforcement, reinforcement learning fundamentals — machine learning
Related Machine Learning Topics