Counterfactual Policy Evaluation answers the fundamental 'what if' question in reinforcement learning by applying importance sampling or direct method estimators to logged data. It corrects for the distributional shift between the logging policy that collected the data and the target evaluation policy, providing an unbiased estimate of expected returns. This enables safe, pre-deployment auditing of autonomous systems.
Glossary
Counterfactual Policy Evaluation

What is Counterfactual Policy Evaluation?
Counterfactual Policy Evaluation (CPE) is a family of off-policy evaluation techniques that estimate the potential performance of a new policy using only historical data generated by a different behavior policy, without deploying the new policy in a live environment.
Key CPE methods include Inverse Propensity Scoring (IPS), which reweights historical rewards by the probability ratio of actions under the target versus behavior policy, and Doubly Robust (DR) estimation, which combines a learned reward model with IPS to reduce variance. These techniques are critical for explaining potential policy outcomes in high-stakes domains like healthcare and finance before real-world execution.
Key Features of CPE
Counterfactual Policy Evaluation estimates how a new policy would perform using only historical data, eliminating the risk of deploying untested policies in production environments.
Off-Policy Estimation Without Deployment
CPE answers the fundamental question: 'What would have happened if we used a different policy?' using only logged data from a previous behavior policy. This avoids costly and potentially dangerous online A/B testing. The core mechanism applies importance sampling or doubly robust estimation to reweight historical trajectories, correcting for the distribution shift between the logging policy and the target evaluation policy.
Inverse Propensity Scoring (IPS)
IPS is the foundational statistical technique for CPE. It reweights each observed trajectory by the ratio of the target policy's action probability to the behavior policy's action probability. Key properties:
- Unbiased when the behavior policy has full support
- High variance when the ratio is large, requiring clipping or self-normalization
- Forms the basis for advanced estimators like Doubly Robust and Weighted IPS
Doubly Robust Estimation
The Doubly Robust (DR) estimator combines IPS with a direct method reward model. It remains consistent if either the propensity model or the reward model is correctly specified, providing a crucial safety net. The DR formula:
- Starts with the direct method estimate of the value
- Adds an IPS correction term on the residuals
- Achieves lower variance than pure IPS while maintaining asymptotic unbiasedness
High-Confidence Off-Policy Evaluation
Beyond point estimates, CPE must quantify uncertainty to support safe policy deployment. Techniques include:
- Bootstrap confidence intervals on the estimated policy value
- Concentration inequalities like Hoeffding's or Bernstein bounds adapted for off-policy data
- Studentized statistics that account for the heavy-tailed nature of importance-weighted returns This transforms CPE from a simple estimate into a rigorous statistical test for policy improvement.
Handling Sequential Decisions
In sequential settings like reinforcement learning, the importance weight becomes a product of action probabilities across the entire trajectory. This causes exponential variance growth with horizon length. Solutions include:
- Step-wise importance sampling that reweights per-transition instead of per-trajectory
- Marginalized importance sampling that estimates state distribution ratios directly
- Stationary distribution correction for infinite-horizon average reward settings
Model-Based vs Model-Free CPE
CPE methods span a spectrum of model reliance:
- Model-Free: Pure importance sampling approaches that require no environment model but suffer from high variance
- Model-Based: Learn a transition and reward model from historical data, then simulate the target policy. Lower variance but introduces model bias
- Hybrid: Methods like MAGIC (Model And Guided Importance sampling Combining) that blend both approaches, adaptively weighting model-based and model-free estimates to minimize mean squared error
Frequently Asked Questions
Addressing the most common technical questions about estimating new policy performance using only historical data, without the risk of online deployment.
Counterfactual policy evaluation (CPE) is a family of off-policy evaluation (OPE) techniques that estimate how a new target policy would perform using only historical data collected by a different logging policy. It answers the 'what if' question without deploying the new policy into a live environment. The core mechanism involves importance sampling (IS) to re-weight historical trajectories, correcting for the distributional shift between the logging policy and the target policy. Advanced methods like doubly robust (DR) estimation combine importance sampling with a learned reward model to reduce variance. For example, in a recommendation system, CPE can predict the click-through rate of a new ranking algorithm using logs from the current production algorithm, preventing costly A/B tests that might degrade user experience.
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 concepts for interpreting and auditing policies evaluated through counterfactual methods.
Off-Policy Evaluation (OPE)
The broader family of techniques that estimate a target policy's performance using data collected from a different behavior policy. Counterfactual Policy Evaluation is a subset of OPE that specifically estimates what would have happened under an alternative policy.
- Key methods: Importance Sampling, Doubly Robust, Fitted Q-Evaluation
- Core challenge: Correcting for distribution shift between logging and target policies
- Variance control: Clipping importance weights to reduce estimator variance
Importance Sampling (IS)
A statistical re-weighting technique that corrects for the mismatch between the behavior policy that collected historical data and the evaluation policy being assessed. Each trajectory is weighted by the ratio of action probabilities under the two policies.
- Step-wise IS: Multiplies probability ratios across all timesteps in a trajectory
- Per-decision IS: Applies weights only up to the relevant decision point, reducing variance
- Weighted IS: Normalizes weights to sum to one, trading bias for lower variance
Doubly Robust Estimator
A hybrid estimator that combines importance sampling with a learned value function model to provide unbiased policy evaluation even when one component is misspecified. It blends the direct method's low variance with importance sampling's asymptotic correctness.
- Requires both a reward model and a value function approximator
- Consistent if either the propensity model or the reward model is correctly specified
- Often used as the gold standard for high-stakes counterfactual evaluation
Fitted Q-Evaluation (FQE)
A model-free OPE method that learns a Q-function for the evaluation policy using only historical transition data. It iteratively applies the Bellman operator to approximate the target policy's value without requiring importance weights.
- Advantage: Avoids the high variance of importance sampling in long horizons
- Limitation: Relies on function approximation quality and sufficient state coverage
- Often combined with conservative Q-learning to prevent overestimation bias
Distribution Shift Detection
The process of identifying when the state-action distribution induced by the evaluation policy diverges significantly from the logging data distribution. Critical for determining when counterfactual estimates become unreliable.
- Density ratio estimation: Learns a classifier to distinguish logging vs. target policy data
- Effective sample size: Measures how many independent samples remain after re-weighting
- Uncertainty-aware OPE: Produces confidence intervals that widen under severe shift
Policy Comparison Testing
Statistical hypothesis testing frameworks that determine whether one policy significantly outperforms another using only historical data. Extends counterfactual evaluation from single-policy estimation to pairwise or ranking comparisons.
- Paired estimators: Correlate estimates to reduce variance in the difference
- Multiple testing correction: Controls false discovery rate when comparing many policies
- Enables safe policy improvement without deploying inferior candidates to production

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