Ahmed Doghri Logo Image
Ahmed Doghri

riskbandit

The greedy policy wins the reward column and fails the safety column. riskbandit uses conformal cost bounds to drop violations from 0.733 to 0.007.

riskbandit, a conformal risk-controlled contextual bandit

Greedy Looks Smart Until The Bill Arrives

The reward-greedy policy does exactly what you asked and exactly what you feared. It finds reward, then blasts through the cost budget.

riskbandit makes that tradeoff visible. The synthetic logged data has contexts, actions, rewards, and costs. The benchmark trains reward and cost models, then asks which policy survives a budget.

Conformal Bounds As A Gate

The conformal policy calibrates cost residuals on held-out logged data. At decision time, it only considers actions whose upper cost estimate fits the budget, then chooses the best remaining reward.

That makes safety a selection rule, not a paragraph in the README. If every risky action is blocked, it falls back to the safe action.

The Number

Reward-greedy averages 0.774 reward with 0.733 violation rate. The conformal policy averages 0.572 reward with 0.007 violation rate. The safe action gets 0.442 reward with zero violations.

3 tests pass locally and on GitHub Actions across Python 3.9, 3.11, and 3.13.

Tools Used

Python
Contextual Bandits
Conformal Prediction
Safe RL
Offline Evaluation
pytest
GitHub Actions CI