How does reinforcement learning work? Explain agent, environment, reward and policy.
An agent takes actions in an environment, receives a reward and a new state, and learns a policy (a rule for choosing actions) that maximises total reward over time. It learns by trial and error, not from labelled examples.
Explain it simply
Training a dog is a good picture. The dog (agent) is in the garden (environment). It sits (action), you give a biscuit (reward). Over many tries the dog learns that sitting on command pays off. Nobody gave the dog a labelled dataset.
The four words to know:
- Agent: the learner and decision maker.
- Environment: everything the agent interacts with.
- Reward: a number telling the agent how good the last action was.
- Policy: the agent's strategy, a mapping from situation to action.
Example
A tiny example: a delivery bot on a grid earns +10 for reaching the customer, -1 for each step, and -5 for hitting a wall.
Step 1: bot at start, picks "right" -> reward -1
Step 2: picks "right" again -> reward -1
Step 3: hits wall -> reward -5
...
Reached customer -> reward +10
Total = -1 -1 -5 ... +10The goal is the highest total (the return), not the biggest single reward. The bot must balance exploration (trying new moves) against exploitation (repeating moves known to be good). Q-learning and policy-gradient methods are standard ways to learn the policy.
What to say in the interview
"In reinforcement learning an agent interacts with an environment, gets a reward for each action, and learns a policy that maximises long-term reward. Unlike supervised learning, there is no answer key, and the agent's actions change the data it sees next. The key trade-off is exploration versus exploitation."
Common mistakes
- Confusing reward with label; a reward is feedback after acting, not the correct answer.
- Maximising immediate reward instead of the total over time.