Imitation Learning
Skip the reward function, copy the expert
Reinforcement learning requires a reward signal, and designing a good one is often the hardest part of the problem. Imitation learning offers a shortcut: if you already have examples of an expert performing the task well — a human driving, a skilled operator controlling a robot arm — just train a policy to reproduce that behavior directly. No reward function required, no exploration needed. It's supervised learning dressed up for sequential decision-making.
Behavioral cloning: the simplest approach
Behavioral cloning (BC) treats imitation as ordinary supervised learning: collect a dataset of (state, action) pairs from the expert, and train a policy network to predict the expert's action given the state, using a standard loss like cross-entropy or mean squared error. It's simple, fast, and works surprisingly well when the task is short or the expert's behavior is highly predictable from the state alone.
Note
DAgger: closing the distribution gap
DAgger (Dataset Aggregation) fixes this by involving the expert iteratively rather than only once upfront. The current policy is run in the environment, which generates new states — including the off-distribution ones BC never sees. At those states, the expert is queried for what it *would* have done, those labels are added to the training set, and the policy is retrained on the growing, now much more representative dataset. Over several rounds, the training distribution comes to match the distribution the policy actually encounters at test time, eliminating the mismatch that caused compounding errors.
Note
Behavioral cloning vs. DAgger
| Aspect | Behavioral cloning | DAgger |
|---|---|---|
| Data collection | One-shot, upfront, offline | Iterative — expert labels states the policy itself visits |
| Distribution match | Trained only on expert's states | Trained on states the learned policy actually visits |
| Error compounding | Severe — errors push policy off-distribution | Much reduced — training covers off-distribution states |
| Expert requirement | Just a static dataset | Interactive expert queryable during training |
What's next
Imitation learning answers 'how do I copy expert behavior'; inverse reinforcement learning answers the deeper question of what reward the expert was actually optimizing, which can generalize further. When no expert demonstrations exist at all and rewards are hard to come by, see the sparse rewards problem and curiosity-driven exploration lessons for how agents learn from scratch instead.
I build these systems professionally.
Whether it's a RAG pipeline, analytics migration, or AI workflow — let's talk.