Reinforcement Learning Lab

Eight reinforcement-learning labs: classical, deep, policy optimisation, bandits, planning and multi-agent, with experiments trained for real in your browser.

39interactive experiments

Contextual bandits and LinUCB

Multi-Armed Bandits · bandits

Learning objectives

  • Understand the effect of context.
  • Know the linear form.

The idea

Here the agent sees a context vector x before choosing, and the best arm depends on it.

Explanation

LinUCB assumes the mean is linear in the context for each arm, keeping a ridge-regression estimate with a confidence bound. It underlies many recommender systems, but the linearity assumption can fail.

Equations

\hat\theta_a=A_a^{-1}b_a,\qquad p_{a}=x^\top\hat\theta_a+\alpha\sqrt{x^\top A_a^{-1}x}

A_a accumulates x·xᵀ plus a regularisation term.

Worked example

"Contextual bandit": LinUCB beats the context-blind policy because the simulated data are truly linear.

Common mistakes

Generalising the result to non-linear data.

Summary

Context changes the best arm; LinUCB learns a linear model per arm.

Related experiments

Assessment questions

References

  1. Auer, P.; Cesa-Bianchi, N.; Fischer, P. (2002). Finite-time analysis of the multiarmed bandit problem. Machine Learning 47:235-256. doi:10.1023/a:1013689704352