This repository contains the code for Optimized Certainty Equivalent Risk-Controlling Prediction Sets, a framework that extends standard RCPS to handle general OCE risk measures such as CVaR (Conditional Value-at-Risk) and entropic risk. The method provides finite-sample, distribution-free guarantees on risk measures beyond the standard expected loss. Some elements are still in progress.
If the code or the paper has been useful in your research, please add a citation to our work:
@article{huang2026optimized,
title={Optimized Certainty Equivalent Risk-Controlling Prediction Sets},
author={Huang, Jiayi and Farzaneh, Amirmohammad and Simeone, Osvaldo},
journal={arXiv preprint arXiv:2602.13660},
year={2026}
}
Figure: Given an input
.
├── core/
│ ├── bounds_oce.py # Concentration bounds (WSR, HB) for OCE risk measures
│ └── concentration_oce.py # UCB computation, t-candidate generation, lambda selection
├── risk_histogram_oce.py # Main experiment runner and plotting
├── PraNet/
│ ├──process_all_datasets.py # Inference script for generating predictions
│ ├──.cache/ # Precomputed loss/size tables
├──outputs/ # Experiment results and plots
The code is based on PyTorch and requires a few common dependencies. It should work with newer versions as well.
(1) Download datasets: Place the polyp segmentation datasets under ./PraNet/data/TestDataset/, including Kvasir, HyperKvasir, CVC-ClinicDB, CVC-ColonDB, and ETIS-LaribPolypDB, which can be found in this link.
(2) Download PraNet weights: Place the pretrained model at ./PraNet/snapshots/PraNet_Res2Net/PraNet-19.pth, downloaded from link.
(3) Generate predictions: One can python ./PraNet/process_all_datasets.py with the default settings, which runs ParNet inference on all datasets and saves inference results to target folder.
(4) Precompute loss and size tables: Generate .npy files containing per-sample losses and prediction set sizes for each lambda value, and place them in ./.cache/.
In order to reproduce the results presented in this paper, one can run python ./risk_histogram_oce.py with different parameter settings as described below.
| Argument | Type | Default | Description |
|---|---|---|---|
--gamma |
float |
0.2 |
Target risk level. |
--delta |
float |
0.2 |
Targer confidence parameter. |
--beta |
float |
0.9 |
CVaR concentration level / entropic risk aversion. |
--bounds |
str |
'WSR' |
Concentration bounds to use. |
--risk_types |
str |
'cvar' |
Particular OCE risk measure. |
For instance, to obtain the presented results, i.e., OCE-RCPS, on the tumor segmentation dataset using a user-defined tolerated risk level
python ./CAb.py --gamma 0.2 --delta 0.2 --beta 0.9 --bounds 'WSR' --risk_types 'cvar'
By utilizing the inference results generated by the PraNet, this configuration reproduces the OCE-RCPS behavior under the specified settings.
standard— Standard RCPS with expected losscvar— OCE-RCPS with CVaR risk (with UCB)entropic— OCE-RCPS with entropic risk (with UCB)crc_cvar— CRC baseline with CVaR risk (no UCB)crc_entropic— CRC baseline with entropic risk (no UCB)
WSR— WaudbySmith and Ramda UCB (SOTA, recommended)HB— Hoeffding UCB
If you have any questions or doubts, please feel free to open an issue in this repository or reach out to me at the provided email addresses: jiayi.3.huang@kcl.ac.uk .