High-Confidence Evaluation & Safe Improvement
Confidence bounds on a policy’s value, and deploying only what is provably better.
A point estimate of a new policy's value is not enough to deploy it. A hospital wants a statement like "with 95% confidence, the new policy is at least as good as the current one", and with importance weights that is harder than it sounds: the estimates are heavy-tailed, and the usual error bars either mislead or say nothing. This lesson builds lower bounds that survive heavy tails, bootstrap intervals and what they give up, the safety test that turns a bound into guaranteed improvement (HCPI and Seldonian algorithms), and the alternative of improving only where data are plentiful (SPIBB and robust MDPs).
What you’ll learn
- Explain why central-limit and Hoeffding intervals fail for importance-weighted returns.
- Derive the truncated empirical-Bernstein lower bound of high-confidence off-policy evaluation, and compute it.
- Describe bootstrap confidence intervals for off-policy evaluation, and what they do and do not guarantee.
- State the guarantee of high-confidence policy improvement and of Seldonian algorithms, and prove that the data split makes it hold.
- State SPIBB's improvement guarantee, and relate it and robust MDPs to pessimism.
Why the usual error bars fail
Normalize returns to and take importance-weighted returns logged by the behavior, each with mean (Off-Policy Evaluation). Two textbook tools would give a lower bound on , and both fail here.
- Central-limit intervals, , assume the sample mean is nearly Gaussian. Importance-weighted returns are extremely skewed: most weights are tiny and a few are huge, and a modest sample may not contain the rare large values that make up the mean. Its sample variance then underestimates the truth, and the interval is overconfident.
- Hoeffding's inequality is valid for bounded variables, but its width scales with the range, and a product of ratios over steps can reach . With a uniform behavior over two actions, a deterministic target and the range is , and a 95% bound from 100,000 trajectories has a half-width of about 4,000, for a quantity between 0 and 1.
A lower bound that survives heavy tails
Thomas, Theocharous and Ghavamzadeh (2015) made high-confidence off-policy evaluation practical with one observation: for a lower bound, large values can be cut off. Truncate each weighted return at a threshold fixed in advance, . Truncation only lowers the mean, so a lower confidence bound for is also one for , and the lie in , where an empirical Bernstein inequality (Maurer & Pontil, 2009) applies with range instead of .
Truncation can only lower values:
The rescaled variables lie in . For such variables Maurer and Pontil's empirical Bernstein inequality says that, with probability at least , their average mean is at least the sample mean minus minus , where is their sample variance; the factor pays for estimating the variance from the same data. Multiply through by , and chain with the first line:
The threshold trades two errors. A small throws away mass and pulls far below ; a large inflates the range term. The paper chooses by maximizing a prediction of the bound on a small separate slice of the data (one twentieth), because the theorem needs to be independent of the samples it is applied to. In their mountain-car experiment with 100,000 trajectories, Hoeffding-type and untruncated empirical-Bernstein bounds were vacuous while the truncated bound was informative; in a digital-marketing simulator built from a large company's real data, certifying a modest improvement at 95% confidence took about 2 million trajectories.
From truncated weighted returns with threshold , you observe and sample standard deviation . What is the 95% lower bound? (, so .)
Show the answer
0.371
The variance term is and the range term , so the bound is . Without truncation the range would be the largest possible weight; at the range term alone would be about 3.5, more than the whole interval .
Think first Why may the threshold not be chosen to maximize the bound on the same data it is then applied to?
The theorem holds for a fixed . Choosing after looking at the samples reports the best of many bounds, each of which fails with probability , and the chance that the chosen one fails can be much larger than : the multiple-comparisons problem. A separate slice of data for choosing restores the guarantee; so would a union bound over a finite grid of thresholds, at the price of replacing by divided by the grid size.
Bootstrap intervals: tighter, not guaranteed
The bootstrap estimates an estimator's sampling distribution by recomputing it on datasets resampled with replacement from the logged trajectories, and reads a lower bound off a low quantile. Its intervals are much tighter than concentration bounds, and it works with any estimator, weighted and doubly robust ones included. But its coverage is only approximately right, and it is least reliable exactly where importance sampling is hardest: if the data happen to lack the rare high-weight trajectories, so does every resample. Thomas et al.'s policy-improvement work offered it, in its bias-corrected and accelerated (BCa) form, as a "semi-safe" option. Hanna, Stone and Niekum (2017) bootstrapped model-based and weighted doubly robust estimators, obtaining approximate lower bounds from far less data than exact methods need, and derived an upper bound on the bias of a model learned from i.i.d. trajectories, which shows when model-based bounds can be trusted.
import numpy as np
def bootstrap_lower_bound(trajectories, estimator, delta=0.05, B=2000, seed=0):
"""Percentile-bootstrap lower bound on J(pi); estimator(list_of_trajectories) -> float."""
rng = np.random.default_rng(seed)
n = len(trajectories)
estimates = [estimator([trajectories[j] for j in rng.integers(0, n, size=n)])
for _ in range(B)]
return np.quantile(estimates, delta) # approximate: no finite-sample guaranteeThe percentile bootstrap; BCa adjusts the quantile for skewness and bias. The procedure is generic, which is its strength, and its justification is asymptotic, which is its weakness.
A uniform behavior over two actions follows a deterministic 12-step target all the way in about one episode in 4,096. Your 1,000 logged episodes contain none that does. What does a percentile bootstrap of ordinary importance sampling report?
- A wide interval that correctly reflects the uncertainty
- A lower bound equal to the true value
- It cannot be computed
- An interval of zero width at 0: every resample has all weights zero, so the bootstrap is confidently wrong
Show the answer
D. An interval of zero width at 0: every resample has all weights zero, so the bootstrap is confidently wrong
Every resample is drawn from the same 1,000 episodes, so every resampled estimate is 0. The bootstrap can only reflect variability present in the sample. The truncated concentration bound stays valid in the same situation: with every it gives a negative, uninformative lower bound, but it never claims certainty.
Deploy only what passes a safety test
Safe policy improvement asks for an algorithm whose output, with probability at least over the data, performs at least as well as a baseline level , such as an estimate of the current policy's value. Thomas, Theocharous and Ghavamzadeh's high-confidence policy improvement (HCPI, 2015) achieves this by splitting the data:
High-confidence policy improvement (HCPI)
split the logged trajectories into D_c (candidate selection, about 1/5) and D_s (safety test)
on D_c: π_c ← the policy with the best predicted value among those whose lower bound,
predicted for a dataset the size of D_s, clears ρ_-
on D_s: L ← a (1 − δ) lower bound on J(π_c), computed from D_s only
if L ≥ ρ_-: return π_c
else: return "No Solution Found"Candidate selection may use any optimizer and any estimator; to limit overfitting, Thomas et al. searched over mixtures of the initial (baseline) policy and a new one. The safety test uses the data only once.
Proof. The candidate depends only on , so given it is a fixed policy and is still a fresh, independent sample. If , returning it is not a failure. If , the test passes only when , that is, only when the bound fails, which has probability at most given . Averaging over preserves the inequality. Reusing in the test would break the first sentence: the candidate was selected because it looks good on that data.
Thomas et al. used three bounds in the test: the exact truncated bound (safe, but data-hungry), and Student's -test and the BCa bootstrap (semi-safe, needing less data). On a gridworld, mountain car and a digital-marketing problem with real data, their methods improved on the baseline safely but needed more data than ordinary RL, and the semi-safe versions' observed error rates stayed below the allowed in those tests. A variant named Daedalus repeats the procedure as new data arrive.
Thomas, Castro da Silva, Barto, Giguere, Brun and Brunskill (2019) generalized the template beyond expected return. In a Seldonian algorithm the user states behavioral constraints , such as "do not increase the rate of a harmful outcome" or a fairness criterion, each with a confidence level , and the algorithm must ensure for every , returning No Solution Found when it cannot certify a solution. Candidate selection and a safety test do the work again. Their examples included fairness constraints when predicting students' grades and an insulin-dosing policy for type 1 diabetes, tested in a simulator and constrained not to increase the frequency of low blood sugar.
Improve only where the data are rich: SPIBB and robust MDPs
HCPI tests a whole policy at once. Laroche, Trichelair and Tachet des Combes (2019) instead restrict where the new policy may differ from the baseline . Count each state–action pair in the data; the pairs seen fewer than times form the bootstrapped set . Safe policy improvement with baseline bootstrapping (SPIBB) optimizes in the maximum-likelihood MDP , but only over policies that copy the baseline's probabilities on :
Policy iteration in with a projected greedy step does this: in each state the baseline's probability on bootstrapped actions stays where it is, and the remaining probability goes to the best well-estimated action.
The term comes from a uniform bound on the error of every estimated next-state distribution, so the error scales like . Plugging in shows how conservative it is: with 20 states, 4 actions, , , and , the error term is about 26, far more than any possible improvement. In practice is treated as a hyperparameter, at values where the bound is loose, and the evidence for SPIBB's safety is experimental: in Laroche et al.'s experiments both of its variants were safe, and they improved on the baseline in most settings. Soft-SPIBB (Nadjahi, Laroche & Tachet des Combes, 2019) constrains, rather than freezes, the probabilities on uncertain pairs.
Petrik, Ghavamzadeh and Chow (2016) took the robust route. Build an uncertainty set of transition models around , shrinking with the counts, and choose the policy that maximizes the worst-case improvement over the baseline across the set, minimizing what they call robust baseline regret. Solving this exactly is NP-hard, and they give approximations. The methods of this lesson are three faces of one principle: a robust MDP is pessimism over models, SPIBB is pessimism that defers to the baseline wherever it is unsure, and HCPI is pessimism about one number, the candidate's value (Pessimism: The Theory of Offline RL).
| Method | What is guaranteed | Main assumptions | Price |
|---|---|---|---|
| Truncated concentration bound | with probability | independent trajectories, logged propensities, returns in | many trajectories when weights are heavy-tailed |
| Bootstrap bound | approximately the same | as above, plus asymptotics | no finite-sample guarantee |
| HCPI, Seldonian algorithms | the returned policy is no worse than (or the constraints hold) with probability | a valid bound and a held-out test set | may return No Solution Found |
| SPIBB | true improvement at least the estimated one minus an error | finite MDP, counts per pair | a conservative error term; chosen by hand |
| Robust baseline regret | worst-case improvement over an uncertainty set | the true model lies in the set | NP-hard to optimize exactly |
Key takeaways
- Importance-weighted returns are heavy-tailed: central-limit intervals are overconfident, and Hoeffding intervals scale with the largest possible weight and are usually vacuous.
- Truncating at a threshold chosen on held-out data keeps a lower bound valid and replaces the range by : .
- Bootstrap intervals are tighter and work with any estimator, but their coverage is only approximate and fails exactly when rare large weights are missing from the sample.
- Safe policy improvement (HCPI, Seldonian algorithms) selects a candidate on one part of the data and certifies it on another, returning No Solution Found otherwise; the split is what makes the guarantee hold. SPIBB instead keeps the baseline's probabilities on rarely seen pairs, and robust MDPs optimize the worst case over plausible models: all three are forms of pessimism.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Why does the high-confidence lower bound truncate the importance-weighted returns at a threshold ?
- To make the estimator unbiased
- To remove the bias toward the behavior policy
- Truncation can only lower the mean, so the bound stays valid for , while the range in the concentration inequality drops from the largest possible weight to
- To make the weighted returns Gaussian
Show the answer
C. Truncation can only lower the mean, so the bound stays valid for , while the range in the concentration inequality drops from the largest possible weight to
For a lower bound, discarding the upper tail is safe: . What it buys is a range of in the empirical Bernstein inequality, instead of a range that grows exponentially with the horizon.
In high-confidence policy improvement, why must the safety test use data that were not used to choose the candidate policy?
- Because the candidate was selected for looking good on its selection data, so a bound computed on the same data is biased upward and can fail far more often than
- Because the safety test needs more data than candidate selection
- Because importance sampling cannot be applied twice to the same data
- Because the behavior policy differs between the two sets
Show the answer
A. Because the candidate was selected for looking good on its selection data, so a bound computed on the same data is biased upward and can fail far more often than
Given the selection data, the candidate is a fixed policy and the test data are a fresh sample, so the bound holds with probability . Reusing the selection data is a multiple-comparisons error: the winner of a search is, on its own data, systematically overestimated.
A percentile bootstrap gives a "95%" lower bound for an importance-sampling estimate. What is guaranteed?
- That the bound fails with probability at most 5%, for any sample size
- Nothing exact: coverage is only approximately 95%, and can be far worse with heavy-tailed weights and small samples
- That the bound lies below the true value
- That the bound is valid whenever the estimator is unbiased
Show the answer
B. Nothing exact: coverage is only approximately 95%, and can be far worse with heavy-tailed weights and small samples
The bootstrap is justified asymptotically. It can only reflect variability present in the sample; if the rare high-weight trajectories are missing, every resample lacks them too.
What does SPIBB's restriction to the policy set do?
- It forbids every action that the baseline takes rarely
- It makes the new policy deterministic
- It copies the baseline only in states that were never visited
- On state–action pairs seen fewer than times it keeps the baseline's probabilities, so the policy changes only where the estimated model is reliable
Show the answer
D. On state–action pairs seen fewer than times it keeps the baseline's probabilities, so the policy changes only where the estimated model is reliable
Where data are scarce, SPIBB defers to the baseline rather than to the estimated model; elsewhere it optimizes freely in the maximum-likelihood MDP. That is why its error term depends on and not on the smallest count in the data.
Further reading
- P. S. Thomas, G. Theocharous & M. Ghavamzadeh, "High-confidence off-policy evaluation," Proceedings of the 29th AAAI Conference on Artificial Intelligence, 3000–3006 (2015).
- P. S. Thomas, G. Theocharous & M. Ghavamzadeh, "High confidence policy improvement," Proceedings of the 32nd International Conference on Machine Learning (ICML), 2380–2388 (2015).
- J. P. Hanna, P. Stone & S. Niekum, "Bootstrapping with models: Confidence intervals for off-policy evaluation," Proceedings of the 16th International Conference on Autonomous Agents and Multiagent Systems (AAMAS) (2017).
- P. S. Thomas, B. Castro da Silva, A. G. Barto, S. Giguere, Y. Brun & E. Brunskill, "Preventing undesirable behavior of intelligent machines," Science 366, 999–1004 (2019).
- R. Laroche, P. Trichelair & R. Tachet des Combes, "Safe policy improvement with baseline bootstrapping," Proceedings of the 36th International Conference on Machine Learning (ICML) (2019).