Offline RL evaluation limits
Quick answer
Offline reinforcement learning fits policies using a fixed logged dataset without collecting additional actions. Its central challenge is that a policy may choose actions that were rarely or never observed, so estimated outcomes may be unreliable. Examples are static Python snippets tested locally on CPU; Only Python standard-library modules are required. ByteMind execution is unverified.
Trajectory importance ratio
from fractions import Fraction as Fmu=[F(1,2),F(1,4)];pi=[F(1,2),F(1,2)]w=F(1)for p,m in zip(pi,mu):w*=p/mprint(w)Expected output (locally tested): 2. The product gives the likelihood ratio for this logged trajectory only.
How it works
Behavior policy mu generated the log; target policy pi is evaluated or learned from it. A necessary support condition for importance sampling is mu(a|s)>0 wherever pi(a|s)>0 at reachable states. The trajectory ratio is the product of pi(a_t|s_t)/mu(a_t|s_t); multiplying by return yields ordinary importance sampling under valid logging probabilities and matching dynamics. Long products may have very high variance. Weighted importance sampling normalizes by total weights, which can reduce variance but introduces finite-sample bias; zero total weight makes it undefined. Neither fixes absent support. A fitted value estimator may extrapolate optimistically; conservative offline RL attempts to control this risk but does not guarantee safety. Partial observability, changing transition dynamics, missing rewards and hidden confounders can invalidate offline estimates. Separate logged trajectories by episode or collection group, not random steps; estimate uncertainty at episode level or by independent training seeds. In a simulator, freeze policies before evaluation and use independent evaluation randomness, identical start-state rules and bounded episodes. Report mean return, variance, success, failures and truncations; do not equate simulator rewards with real outcomes. Reward hacking, simulator mismatch and unmodeled constraints need independent checks. No physical actuators, trading, external actions or deployment are part of this chapter.
Population reward variance
from statistics import pvariance,meanr=[-2,2,4,4]print(mean(r),pvariance(r))Expected output (locally tested): 2 6. Variance measures dispersion even when the mean return is positive.
Common mistakes
Do not divide by zero logging probability, treat unseen actions as known failures, or call a small simulator benchmark a deployment guarantee. Avoid reusing evaluation episodes to tune policies.
Practice and next steps
For one logged trajectory with behavior probabilities [0.5,0.25] and target probabilities [0.5,0.5], compute its importance weight. Explain why a target action absent from logs is a different problem from high variance.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Offline RL evaluation limits — knowledge check
Apply offline rl evaluation limits to small examples and debugging scenarios.
What is offline RL?
What does support require?
Why can trajectory importance ratios be unstable?
What is an appropriate unit for splitting trajectories?
What does a high simulated return establish?