Counterfactual evaluation is an off-policy evaluation technique that estimates how a new decision-making policy would perform if deployed, using only historical data generated by a different, previously deployed logging policy. It answers the "what if" question by correcting for the selection bias inherent in logged data, where we only observe outcomes for actions the old policy chose, not the ones the new policy might have taken. This is critical for safely validating models like contextual multi-armed bandits before exposing them to live traffic.
Glossary
Counterfactual Evaluation

What is Counterfactual Evaluation?
A statistical method for estimating the performance of a new policy using historical data collected under a different logging policy, without deploying the new policy live.
The core mechanism relies on importance sampling estimators, such as the Inverse Propensity Scoring (IPS) estimator, which re-weights observed rewards by the ratio of the target policy's probability to the logging policy's probability for a given action. More advanced techniques like the Doubly Robust estimator combine IPS with a direct reward model to reduce variance and maintain unbiasedness even if one component is misspecified. This provides a principled alternative to risky online A/B tests for high-stakes personalization.
Key Characteristics of Counterfactual Evaluation
Counterfactual evaluation is a statistical methodology for estimating the performance of a new target policy using only historical data collected by a different logging policy. It answers the critical question: 'How well would this new model have performed without ever deploying it live?'
The Fundamental Problem of Causal Inference
Counterfactual evaluation addresses the core challenge that we can only observe the outcome of the action that was taken, not the outcomes of actions that were not taken. The logged data contains the factual outcome for the chosen action, but the counterfactual outcomes for all other possible actions remain unobserved. This missing data problem is the central obstacle that off-policy estimators must overcome to provide unbiased performance estimates.
Inverse Propensity Scoring (IPS)
IPS is the foundational off-policy estimator that corrects for selection bias by re-weighting each observed reward by the inverse of the probability that the logging policy chose that action. The core formula is:
- Estimator: ( V_{IPS} = \frac{1}{N} \sum_{i=1}^{N} \frac{\pi_e(a_i|x_i)}{\pi_b(a_i|x_i)} r_i )
- Key Requirement: The logging policy (\pi_b) must have a non-zero probability of selecting any action the target policy (\pi_e) might select (common support)
- Variance Challenge: IPS can suffer from high variance when the logging and target policies diverge significantly, leading to large importance weights
Doubly Robust Estimation
The doubly robust estimator combines IPS with a direct method reward model to provide a more reliable estimate. It remains unbiased if either the propensity model or the reward model is correctly specified, providing a crucial safety net:
- Direct Method Component: Learns a model (\hat{r}(x, a)) to predict the reward for any context-action pair
- Correction Term: Adds an IPS-weighted correction for the residuals of the direct method predictions
- Practical Advantage: In real-world applications where perfect propensity or reward models are rare, the doubly robust estimator often exhibits significantly lower variance than pure IPS
The Common Support Assumption
For off-policy evaluation to be valid, the logging policy must have explored the action space sufficiently. The common support or overlap condition requires that for any context where the target policy assigns a non-zero probability to an action, the logging policy must also have a non-zero probability of selecting that action:
- Violation Consequence: If the target policy selects actions the logging policy never tried, the estimate becomes biased and unreliable
- Detection: Inspect the distribution of propensity scores and importance weights for extreme values
- Mitigation: Clip importance weights or use self-normalized estimators to trade some bias for reduced variance
Off-Policy vs. On-Policy Evaluation
Understanding the distinction between evaluation paradigms is critical for safe model deployment:
- On-Policy Evaluation: The model being evaluated is the same model that collected the data. Requires no correction but demands live deployment
- Off-Policy Evaluation: The target model differs from the data-collecting logging model. Enables safe, pre-deployment assessment but requires statistical correction
- A/B Testing: The gold-standard on-policy method that randomly assigns users to control and treatment groups, directly measuring causal impact without modeling assumptions
- Counterfactual Advantage: Allows rapid iteration on model candidates without the business risk or time cost of live experiments
Variance Reduction Techniques
High variance in off-policy estimates can render them useless for decision-making. Key techniques to stabilize estimates include:
- Weight Clipping: Capping importance weights at a maximum threshold to prevent any single sample from dominating the estimate
- Self-Normalized IPS: Dividing by the sum of importance weights rather than the sample size N, trading a small amount of bias for dramatic variance reduction
- Control Variates: Subtracting a baseline function from the reward that has a known expected value under the target policy, reducing variance without introducing bias
- Bootstrapped Confidence Intervals: Resampling the logged data to construct empirical confidence intervals around the point estimate
Frequently Asked Questions
Clear, technically precise answers to the most common questions about validating new personalization policies using only historical log data, without risking live user experience.
Counterfactual evaluation is a statistical method for estimating the performance of a new policy using historical data collected under a different logging policy, without deploying the new policy live. It works by answering the counterfactual question: "What would have happened if we had used policy B instead of policy A?" The core mechanism involves re-weighting observed outcomes by the ratio of the target policy's action probability to the logging policy's action probability, a technique known as Inverse Propensity Scoring (IPS). This corrects for the selection bias inherent in logged data, where we only observe outcomes for actions the logging policy chose. The method assumes the logging policy has a non-zero probability of selecting any action the target policy might choose, a condition called common support or overlap. Counterfactual evaluation is the foundation of safe, offline model validation for recommender systems and contextual bandits.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core statistical estimators and evaluation paradigms that enable safe, offline validation of new personalization policies before they touch a single live user.
Direct Method (DM)
The simplest off-policy estimator that trains a regression model to predict the reward for any context-action pair, then evaluates the target policy by averaging the predicted rewards for the actions it would have selected. DM has low variance because it uses smooth model predictions, but it is biased if the reward model is misspecified. It ignores the actual observed rewards entirely during evaluation, relying solely on the learned model. Often used as a baseline or as the model component within a doubly robust estimator.
Propensity Score Clipping
A variance reduction technique applied to IPS estimators. When the logging policy assigned a very small probability to an action, the inverse weight becomes extremely large, causing exploding variance. Clipping caps these weights at a maximum threshold (e.g., 20), trading a small amount of bias for a dramatic reduction in variance. This is a standard production safeguard. The self-normalized IPS variant divides by the sum of weights instead of the count of samples, providing implicit regularization.
Cumulative Distributional Shift
The phenomenon where small per-step differences between the logging policy and the target policy compound over a trajectory, causing the state distribution visited by the target policy to diverge significantly from the logged data. In long-horizon settings like session-based recommendations, this makes standard off-policy estimators exponentially biased. Solutions include step-wise importance sampling and stationary distribution corrections that model the long-term visitation probabilities.
Off-Policy Confidence Intervals
Statistical methods for quantifying the uncertainty of counterfactual estimates. Techniques include bootstrap resampling of logged trajectories, Bernstein-type inequalities that account for the heavy tails of importance-weighted estimators, and empirical Bernstein bounds that adapt to observed variance. Reporting a point estimate without a confidence interval is considered unreliable; production evaluation pipelines must output both the estimated value and its 95% confidence bounds to support safe deployment decisions.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us