Introduction: The Statistical Trap of "Double-Dipping"
Deep learning models excel at identifying regions of interest (ROIs) in complex data, such as potential tumors in MRI scans or anomalies in industrial imaging. However, a significant statistical challenge arises when these models are used for decision-making: the "double-dipping" problem.
When the same data is used both to select a hypothesis (identifying a region) and to test that hypothesis (determining if the region is significant), standard statistical tests become biased. These "naive" p-values often approach zero even when no real signal is present, leading to a high rate of false positives. This lack of reliability hinders the deployment of AI in high-stakes fields like medicine and autonomous safety. si4onnx addresses this by bringing statistical rigor to deep learning "explanations" through automated Selective Inference (SI).
Methods: Automating Selective Inference
The si4onnx package implements a framework that calculates conditional p-values. Instead of a standard test, SI asks: "Given that the model chose this specific region, how likely is it that this result occurred by chance?"
Key technical features include:
- Auto-Conditioning & Parametric Programming: The package treats models using piecewise-linear functions (like ReLU and Max Pooling) as a series of linear inequalities. It traces the input through the network to identify the exact data range that would result in the same ROI selection.
- ONNX Integration: To avoid labor-intensive manual derivations for every architecture,
si4onnxloads models in the universal ONNX format. This makes it compatible with PyTorch, TensorFlow, and other major frameworks. - Preset Hypotheses: The package provides built-in tests to compare an ROI against its background, its neighborhood, or a reference image.
Datasets and Experimental Setup
The framework was validated using:
- BraTS 2023 (T2-FLAIR) MRI images: Demonstrating real-world applications in brain tumor detection, segmentation, and saliency mapping.
- Synthetic Gaussian Data: Used for rigorous simulations to ensure p-values follow a uniform distribution under the null hypothesis, a requirement for valid statistical testing.
Key Results and Insights
The primary insight of this work is the correction of misleading "naive" p-values. In healthy brain images, models might flag a region as anomalous with a naive p-value of 0.000. si4onnx corrects this to a non-significant value (e.g., 0.915), effectively preventing false diagnoses.
Experimental results confirmed:
- Statistical Validity: In null-hypothesis simulations, selective p-values followed a uniform distribution, proving the test correctly controls the false positive (Type I error) rate.
- High Statistical Power: When a real signal was present, selective p-values remained very small, showing the test is powerful enough to detect actual anomalies.
- Versatility: The package was successfully applied to three distinct paradigms: Anomaly Detection (VAE), Image Segmentation (U-Net), and Saliency Mapping (CAM).
Limitations and Future Work
Currently, si4onnx is optimized for piecewise-linear operations. While it supports Sigmoid outputs via logit transformation, it does not yet support non-linear activations like Sigmoid or Tanh within hidden layers. Additionally, computational complexity grows with model size. Future updates aim to integrate parallel computing via the sicore library and expand support for more diverse layer types and hypothesis tests.
Summary updated