liveBook · Manning

Counterfactual outcome

As explained in Experimentation for Engineers

An outcome or associated information that would occur under a different system state or intervention than the one observed.

A counterfactual outcome is what would have happened under a different system decision or state than the one actually observed. In production systems, only the selected action produces a directly logged reward; alternative outcomes remain unknown. section 5.2 section 5.2.1

This missing information creates an online-offline gap. A model trained on historical recommendations learns user responses to the old policy, not necessarily responses to a newly deployed ranking or trading strategy. section 1.3.2

A biased recommendation estimate

Suppose post #1 is shown in three contexts with viewing-time rewards 0.6, 0.9, and 1.3. Linear regression estimates beta_1 = [0.6, 0.9, 1.3]. For User A with context [0,0,1], the predicted reward is 1.3. If post #1 was never shown in that context because post #2 was selected, the fitted coefficient can become beta_1m = [0.6, 0.9, 0], predicting 0.0 instead. The missing alternative observation produces a strongly biased estimate. section 5.2.1

Counterfactual information is managed through deliberate experimentation:

  • Use epsilon-greedy exploration to select alternatives occasionally, accepting a short-term reward cost to collect data for better future predictions. section 5.2
  • Validate the resulting policy with an A/B test rather than relying only on offline predictions. section 5.0
  • Treat simulations as faster and more repeatable than live experiments, but account for bias when real participants respond to deployed actions. section 1.3.3
contexts = [
   [1, 0, 0],
   [0, 1, 0],
   [0, 0, 1]
]
rewards = [
   0.6,
   0.9,
   1.3
]

Inspect the toy contexts and rewards used to show how observed action data supports prediction while unobserved alternatives remain unavailable. section 5.2.1

How Experimentation for Engineers covers it

How deep it goes
Explains missing-data bias numerically, then connects exploration, policy logging, A/B testing, and simulation limitations.
Examples
Uses article ranking, post recommendations, trading strategies, and a three-context viewing-time regression.
What it assumes
Assumes supervised learning and production logging, while developing intuition for contextual bandits and exploration.
What you can do after
Apply epsilon-greedy exploration and controlled experiments to collect alternatives and evaluate decision policies.
How it connects
Connects counterfactual outcomes to contextual bandits, epsilon-greedy exploration, feedback loops, A/B testing, and simulation.

Also explained in

Compare how 4 books explain counterfactual outcome →

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.