← All projects

BanditsTestbed

A tool I built for my students to play, compare, and implement reinforcement learning policies.

ROLE
Developer & instructor
OUTCOME
Built for my students
TOOLS & METHODS
Python · Tkinter · NumPy · Matplotlib
Average-reward curves and action counts from a seeded run of the project’s epsilon-greedy and UCB policies.

A single illustrative run of the project’s policies, plotted for this portfolio; not a performance benchmark.

I built BanditsTestbed for my students to try reinforcement learning before writing an agent of their own. They can make the decisions themselves, compare a few algorithms, then change the policy and see what happens.

The problem is simple to explain: several choices give uncertain rewards. Do you keep choosing the one that looks best, or try something you know less about?

Try it, then compare

The three-arm environment uses dice rewards. Students can pull an arm and work out which one they think is best. The ten-arm environment uses Gaussian reward distributions, with plots that show how the estimates change as more samples come in.

The application includes ε-greedy and upper-confidence-bound policies. ε-greedy occasionally chooses at random; UCB gives less-tested actions an uncertainty bonus. Running them side by side makes it easier to discuss why they make different choices, even with similar estimates.

One exercise is to pause a run and predict the next action. That gives us something specific to discuss before going back to the equation.

Write a policy

The environment, interface, and policy code are separate. Students initialize their policy, then choose actions using the reward estimates, counts, and history. The application handles the sampling and plotting.

I wanted the exercise to stay focused on the decision rule. Students should be able to change an idea and try it without first building a desktop interface. The application uses Python, Tkinter, NumPy, and Matplotlib, and I’m continuing to develop it as a teaching tool.

Explore the source.

← All projectsNext: RoCo →