Define the imitation task
Specify the environment, observation and action formats, and what constitutes an expert demonstration before collecting trajectories.
Imitation learning from demonstrations. Compare learned and expert actions.
Imitation learning trains a policy to mimic expert behaviour from collected trajectories. Key tasks include defining state and action spaces, gathering representative expert demonstrations, choosing an algorithm (behavioural cloning, AIRL, GAIL), and measuring agreement with expert actions plus downstream task return.
Learning concept · Not a validated service
Imitation learning trains a policy to mimic expert behaviour from collected trajectories. Key tasks include defining state and action spaces, gathering representative expert demonstrations, choosing an algorithm (behavioural cloning, AIRL, GAIL), and measuring agreement with expert actions plus downstream task return.
A proposed application: help a research team prototype an autonomous agent that reproduces expert demonstrations in a simulator. Human experts should remain in the loop to review behaviour and intervene; this starter does not deliver a deployable controller.
Specify the environment, observation and action formats, and what constitutes an expert demonstration before collecting trajectories.
Convert trajectories into state-action pairs, normalise observations and split into train/validation sets.
Fit a supervised behavioural-cloning model on state-action pairs and validate by measuring action agreement with held-out expert data.
Run the learned policy in the simulator to measure average return, divergence from expert behaviour and failure cases.
The supplied starter simulates a multi-armed bandit using an epsilon-greedy strategy: it defines fixed per-action reward probabilities, selects actions by explore/exploit, updates sample-average reward estimates online, and prints action counts, estimated rates and total reward.
for step in range(1, 2001):
if rng.random() < epsilon:
action = rng.integers(len(true_reward_rates))
else:
action = int(np.argmax(estimated_values))
reward = 1 if rng.random() < true_reward_rates[action] else 0
action_counts[action] += 1
total_reward += reward
estimated_values[action] += (reward - estimated_values[action]) / action_counts[action]The code does not load expert demonstrations, define an environment, or train a policy to imitate an expert. Instead it runs a bandit simulation that estimates per-action reward rates; it does not implement behavioural cloning, inverse reinforcement learning, or any imitation algorithm.
A proposed extension: replace the synthetic bandit with collected expert trajectories from a simulator, implement behavioural cloning (supervised policy learning) and evaluate both action-matching metrics and episodic return in-environment.
This is a potential application pathway, not a delivered product. The supplied starter does not implement this service or validate it with real users.
Networkers Home runs this topic inside its AI Engineer Course, with placement support and hands-on labs.