liveBook · Manning

Epsilon-greedy

As explained in Experimentation for Engineers

Epsilon-greedy is a bandit allocation method that usually selects the currently best alternative while exploring alternatives at a specified probability.

Epsilon-greedy is a multi-armed bandit allocation rule for evaluating production alternatives while limiting the cost of serving weaker ones. Rather than split traffic equally as in an A/B test, it adapts allocation toward the alternative with the best observed business metric, such as click-through rate (CTR). section 3.0 section 3.1.2

On each decision, exploit with probability 1 − ε by selecting the arm with the highest mean reward observed so far. Explore with probability ε by selecting uniformly at random among the arms. ε is a system-specific metaparameter: ε = 1 behaves like equal randomization, while ε = 0 never deliberately explores. section 3.1.2

Figure 3.6 Using epsilon-greedy to test a click model. With probability 1 - epsilon, epsilon-greedy chooses the click model with the higher CTR so far. Otherwise, with probability epsilon, it randomly chooses between A and B.
03-06

The decision flow makes the split explicit: observed CTR determines the usual choice, while ε preserves randomized measurements of both alternatives. section 3.1.2

Testing two click models

An ad selector compares model A, with simulated CTR 0.0050, against model B, with CTR 0.0070. At ε = 0.10, it uses the currently higher-CTR model 90% of the time and randomizes 10% of the time. A simulated run reaches about 0.0067 CTR, above an equal-split test’s roughly 0.0058 while remaining below the known-best model’s 0.0070. section 3.1.1 section 3.1.2

Operate epsilon-greedy with these practical safeguards:

  • Track each arm’s reward sum and number of selections; use the resulting mean reward as the exploitation estimate. section 3.1.2
  • Keep exploration nonzero long enough to avoid locking onto an early, noisy winner; too little exploration can select the wrong version. section 3.1.3
  • For a stopping rule, decay ε approximately as 1/n and stop once it falls below a chosen small threshold; lower thresholds run longer. section 3.1.3
  • Extend the same rule to K arms: exploit the highest mean-reward arm or explore uniformly across all available arms. section 3.2

In contextual recommendation, epsilon-greedy also turns a prediction-only policy into an experiment: occasional random recommendations collect outcomes for actions that the greedy policy would not show. Those counterfactual observations can reduce prediction-model bias and feedback loops, at a short-term experimentation cost. section 5.2 section 5.2.2

The method favors business-metric performance during evaluation over the fixed-sample inference goal of a conventional A/B test. It is simple to implement and has optimal asymptotic regret, but tuning ε is system-dependent; Thompson sampling is presented as an alternative with stronger operational metric performance and no such metaparameter. section 3.4

How Experimentation for Engineers covers it

How deep it goes
Defines the decision rule, supplies Python simulations, covers decayed stopping, and generalizes from two alternatives to multiple arms.
Examples
Uses ad click models with CTR rewards and a social-media recommender that randomly shows some posts.
What it assumes
Builds from A/B-test randomization and assumes a directly measurable short-term business-metric reward.
What you can do after
Apply it via a Python/NumPy-style policy to allocate among alternatives while tracking observed rewards and tuning exploration.
How it connects
Connects multi-armed bandits with A/B testing, click-through rate, contextual bandits, counterfactuals, regret, and Thompson sampling.

Also explained in

Compare how 3 books explain epsilon-greedy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Experimentation for Engineers. The section links point to the parts of the book it draws on.