ML Systems Lab Open interactive version →
Advanced 60 min read LinUCBridge regressionconfidence ellipsoidSherman-Morrisondisjoint

LinUCB In Depth

Ridge regression reward model, confidence ellipsoid, disjoint vs hybrid, Sherman-Morrison

LinUCB is contextual bandit theory turned into a deployable algorithm. The core insight is geometric: to know how uncertain you are about the reward at a given context x, you need to know how far x is from the contexts you have actually observed. If x is in a direction where you have abundant observations (span of historical contexts), your estimate is confident. If x is in an under-observed direction, your estimate is uncertain and you should explore. The term x^T A^{-1} x captures exactly this: A = X^T X + λI accumulates the information you have observed, and x^T A^{-1} x is large for contexts in the null space of observed data.

This gives exact O(d√T) regret guarantees with efficient O(d²) online updates via Sherman-Morrison. The Yahoo! news paper found the theory-suggested α was 25× too large — always tune α empirically, never use the theoretical constant.

Key points

Takeaway

x^T A^{-1} x is the central LinUCB quantity: it measures how far the current context is from the span of previously observed data, so the exploration bonus is automatically largest in under-observed directions of context space. The Yahoo! news result — optimal α was 25× smaller than theory predicts — is a reliable reminder that worst-case theoretical constants are not production constants. Always tune α empirically and use Sherman-Morrison O(d²) updates rather than O(d³) full matrix inversions for real-time updates.

Recap

Check your understanding

Q1. Derive the LinUCB index from first principles. Why is √(x^T A^{-1} x) the right uncertainty measure?

Q2. You're implementing LinUCB with d=100 feature dimensions and K=50 arms. The system receives 10,000 requests/second. Describe the computational challenges and how you address them.

Q3. In the Yahoo! news experiment, α=0.2 was optimal, far below the theoretically motivated α=O(√(d ln T)). What does this imply about the theory-practice gap in LinUCB?

Q4. How does LinUCB handle the cold-start problem for a completely new arm that has never been shown to any user? Select the two true mechanisms.

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →