Allocate Homepage Widget Slots With Thompson Sampling
Last updated: November 29, 2026
Quick Overview
You have several candidate homepage widgets (deals, recently viewed, new releases) and want to learn which earns the most clicks while still serving traffic well. Explain and implement a Thompson sampling approach.
Amazon
November 29, 20260
0
0 solved
You have several candidate homepage widgets (deals, recently viewed, new releases) and want to learn which earns the most clicks while still serving traffic well. Explain and implement a Thompson sampling approach.
Amazon pages are assembled from many competing widgets, and bandits are a natural fit for allocating them. The interviewer wants to see you contrast bandits with fixed A/B tests, implement Beta-Bernoulli Thompson sampling, and reason about non-stationarity.
What the Interviewer Expects
- Frame as a multi-armed bandit with Bernoulli rewards
- Implement Beta posterior updates
- Explain why sampling balances exploration and exploitation
- Discuss delayed and non-stationary rewards
- Contrast with a fixed-split A/B test
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- How would you make it contextual, using customer segment?
- How do you handle reward delays when the reward is a purchase hours later?
- How would you report a final 'winner' to stakeholders?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
Confirm the reward (click on the widget, binary) and that arms are fixed for the experiment period. Ask whether we need a clean causal estimate (A/B test) or want to minimize regret while learning (ba...
Approach
Give each arm a Beta(1, 1) prior on click rate. On each request draw , show the arm with the largest draw, and update on a click or otherwis...