Simple Algorithm
Reinforcement Learning · Fixed Point · 28 min

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 [0,1][0,1] and take nn importance-weighted returns Xi=w(i)G(i)X_i = w^{(i)}G^{(i)} logged by the behavior, each with mean J(π)J(\pi) (Off-Policy Evaluation). Two textbook tools would give a lower bound on J(π)J(\pi), and both fail here.

  • Central-limit intervals, Xˉ−z s/n\bar X - z\,s/\sqrt n, 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 HH steps can reach (1/min⁡ab(a∣s))H(1/\min_a b(a\mid s))^H. With a uniform behavior over two actions, a deterministic target and H=20H = 20 the range is 220≈1062^{20}\approx10^6, 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 cc fixed in advance, Yi=min⁡(Xi,c)Y_i = \min(X_i, c). Truncation only lowers the mean, so a lower confidence bound for E[Y]\E[Y] is also one for J(π)J(\pi), and the YiY_i lie in [0,c][0, c], where an empirical Bernstein inequality (Maurer & Pontil, 2009) applies with range cc instead of 10610^6.

DerivationProof
  1. E[Yi] ≤ E[Xi] ≤ J\E[Y_i]\ \le\ \E[X_i]\ \le\ J

    Truncation can only lower values:

  2. J ≥ 1n∑iE[Yi] ≥ Yˉ−2ln⁡(2/δ) sY2n−7cln⁡(2/δ)3(n−1)■J\ \ge\ \frac1n\sum_i\E[Y_i]\ \ge\ \bar Y - \sqrt{\frac{2\ln(2/\delta)\,s_Y^2}{n}} - \frac{7c\ln(2/\delta)}{3(n-1)}\qquad\blacksquare

    The rescaled variables Yi/cY_i/c lie in [0,1][0,1]. For such variables Maurer and Pontil's empirical Bernstein inequality says that, with probability at least 1−δ1-\delta, their average mean is at least the sample mean minus 2Vln⁡(2/δ)/n\sqrt{2V\ln(2/\delta)/n} minus 7ln⁡(2/δ)/(3(n−1))7\ln(2/\delta)/(3(n-1)), where VV is their sample variance; the factor ln⁡(2/δ)\ln(2/\delta) pays for estimating the variance from the same data. Multiply through by cc, and chain with the first line:

The threshold trades two errors. A small cc throws away mass and pulls Yˉ\bar Y far below JJ; a large cc inflates the range term. The paper chooses cc by maximizing a prediction of the bound on a small separate slice of the data (one twentieth), because the theorem needs cc 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.

Predict before you look

From n=10,000n = 10{,}000 truncated weighted returns with threshold c=5c = 5, you observe Yˉ=0.40\bar Y = 0.40 and sample standard deviation sY=0.9s_Y = 0.9. What is the 95% lower bound? (δ=0.05\delta = 0.05, so ln⁡(2/δ)=ln⁡40≈3.69\ln(2/\delta) = \ln40\approx3.69.)

Show the answer

0.371

The variance term is 2×3.69×0.81/10,000≈0.0244\sqrt{2\times3.69\times0.81/10{,}000}\approx0.0244 and the range term 7×5×3.69/(3×9,999)≈0.00437\times5\times3.69/(3\times9{,}999)\approx0.0043, so the bound is 0.40−0.024−0.004≈0.3710.40 - 0.024 - 0.004\approx0.371. Without truncation the range would be the largest possible weight; at 212=40962^{12} = 4096 the range term alone would be about 3.5, more than the whole interval [0,1][0,1].

Think first Why may the threshold cc not be chosen to maximize the bound on the same data it is then applied to?

The theorem holds for a fixed cc. Choosing cc after looking at the samples reports the best of many bounds, each of which fails with probability δ\delta, and the chance that the chosen one fails can be much larger than δ\delta: the multiple-comparisons problem. A separate slice of data for choosing cc restores the guarantee; so would a union bound over a finite grid of thresholds, at the price of replacing δ\delta by δ\delta 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.

python
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 guarantee

The 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.

Check your understanding

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?

  1. A wide interval that correctly reflects the uncertainty
  2. A lower bound equal to the true value
  3. It cannot be computed
  4. 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 Yi=0Y_i = 0 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 1−δ1-\delta over the data, performs at least as well as a baseline level ρ−\rho_-, 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:

text
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 πc\pi_c depends only on DcD_c, so given DcD_c it is a fixed policy and DsD_s is still a fresh, independent sample. If J(πc)≥ρ−J(\pi_c)\ge\rho_-, returning it is not a failure. If J(πc)<ρ−J(\pi_c) < \rho_-, the test passes only when L≥ρ−>J(πc)L\ge\rho_- > J(\pi_c), that is, only when the bound fails, which has probability at most δ\delta given DcD_c. Averaging over DcD_c preserves the inequality. ■\blacksquare Reusing DcD_c 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 tt-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 δ\delta 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 gi≤0g_i\le0, such as "do not increase the rate of a harmful outcome" or a fairness criterion, each with a confidence level δi\delta_i, and the algorithm must ensure Pr⁡(gi(a(D))≤0)≥1−δi\Pr\big(g_i(a(\data))\le0\big)\ge1-\delta_i for every ii, 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 πb\pi_b. Count each state–action pair in the data; the pairs seen fewer than N∧N_\wedge times form the bootstrapped set B\mathfrak B. Safe policy improvement with baseline bootstrapping (SPIBB) optimizes in the maximum-likelihood MDP M^\hat M, but only over policies that copy the baseline's probabilities on B\mathfrak B:

Πb={π: π(a∣s)=πb(a∣s)  for all (s,a)∈B}.\Pi_b = \big\{\pi:\ \pi(a\mid s) = \pi_b(a\mid s)\ \text{ for all } (s,a)\in\mathfrak B\big\}.

Policy iteration in M^\hat M 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 ln⁡2∣S∣=∣S∣ln⁡2\ln2^{\abs{\mathcal S}} = \abs{\mathcal S}\ln2 comes from a uniform bound on the error of every estimated next-state distribution, so the error scales like ∣S∣/N∧\sqrt{\abs{\mathcal S}/N_\wedge}. Plugging in shows how conservative it is: with 20 states, 4 actions, γ=0.9\gamma = 0.9, Vmax⁡=1V_{\max} = 1, δ=0.05\delta = 0.05 and N∧=100N_\wedge = 100, the error term is about 26, far more than any possible improvement. In practice N∧N_\wedge 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 M^\hat M, 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).

MethodWhat is guaranteedMain assumptionsPrice
Truncated concentration boundJ(π)≥LJ(\pi)\ge L with probability 1−δ1-\deltaindependent trajectories, logged propensities, returns in [0,1][0,1]many trajectories when weights are heavy-tailed
Bootstrap boundapproximately the sameas above, plus asymptoticsno finite-sample guarantee
HCPI, Seldonian algorithmsthe returned policy is no worse than ρ−\rho_- (or the constraints hold) with probability 1−δ1-\deltaa valid bound and a held-out test setmay return No Solution Found
SPIBBtrue improvement at least the estimated one minus an errorfinite MDP, counts per paira conservative error term; N∧N_\wedge chosen by hand
Robust baseline regretworst-case improvement over an uncertainty setthe true model lies in the setNP-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 cc: J(π)≥Yˉ−2ln⁡(2/δ)sY2/n−7cln⁡(2/δ)/(3(n−1))J(\pi)\ge\bar Y - \sqrt{2\ln(2/\delta)s_Y^2/n} - 7c\ln(2/\delta)/(3(n-1)).
  • 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.

Question 1

Why does the high-confidence lower bound truncate the importance-weighted returns at a threshold cc?

  1. To make the estimator unbiased
  2. To remove the bias toward the behavior policy
  3. Truncation can only lower the mean, so the bound stays valid for J(π)J(\pi), while the range in the concentration inequality drops from the largest possible weight to cc
  4. To make the weighted returns Gaussian
Show the answer

C. Truncation can only lower the mean, so the bound stays valid for J(π)J(\pi), while the range in the concentration inequality drops from the largest possible weight to cc

For a lower bound, discarding the upper tail is safe: E[min⁡(X,c)]≤E[X]\E[\min(X, c)]\le\E[X]. What it buys is a range of cc in the empirical Bernstein inequality, instead of a range that grows exponentially with the horizon.

Question 2

In high-confidence policy improvement, why must the safety test use data that were not used to choose the candidate policy?

  1. 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 δ\delta
  2. Because the safety test needs more data than candidate selection
  3. Because importance sampling cannot be applied twice to the same data
  4. 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 δ\delta

Given the selection data, the candidate is a fixed policy and the test data are a fresh sample, so the bound holds with probability 1−δ1-\delta. Reusing the selection data is a multiple-comparisons error: the winner of a search is, on its own data, systematically overestimated.

Question 3

A percentile bootstrap gives a "95%" lower bound for an importance-sampling estimate. What is guaranteed?

  1. That the bound fails with probability at most 5%, for any sample size
  2. Nothing exact: coverage is only approximately 95%, and can be far worse with heavy-tailed weights and small samples
  3. That the bound lies below the true value
  4. 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.

Question 4

What does SPIBB's restriction to the policy set Πb\Pi_b do?

  1. It forbids every action that the baseline takes rarely
  2. It makes the new policy deterministic
  3. It copies the baseline only in states that were never visited
  4. On state–action pairs seen fewer than N∧N_\wedge 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 N∧N_\wedge 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 N∧N_\wedge 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).