Skip to content

Examples

Practical examples demonstrating different conformal anomaly detection approaches.

Getting Started

Example Difficulty What You'll Learn
Classical Conformal Beginner Basic split conformal detection, FDR control, p-value interpretation
Cross-Validation Conformal Beginner K-fold cross-validation for better data efficiency

Advanced Strategies

Example Difficulty What You'll Learn
Jackknife Conformal Intermediate Jackknife+ strategy for theoretical guarantees
Bootstrap Conformal Intermediate JaB+ strategy for uncertainty quantification
Conditional Conformal Intermediate Conditionally calibrated conformal p-values with BH-style FDR selection

Special Topics

Example Difficulty What You'll Learn
Weighted Conformal Advanced Handling distribution shift between training and test data
FDR Control Intermediate Multiple testing correction, Benjamini-Hochberg procedure

What Each Example Covers

Classical Conformal - Start here if you're new to nonconform. Learn the core workflow: wrap a detector, compute p-values, and apply FDR control. Includes visualization of results.

Cross-Validation Conformal - Use all your training data for both fitting and calibration using k-fold CV. Good for smaller datasets where you can't afford to reserve data.

Jackknife Conformal - Apply the Jackknife+ strategy, which provides finite-sample theoretical guarantees. A good balance between computational cost and accuracy.

Bootstrap Conformal - Use the Jackknife+-after-Bootstrap (JaB+) strategy for robust uncertainty quantification. Best when you need to understand detection stability.

Conditional Conformal - Apply conditional calibration maps (mc, simes, dkwm, asymptotic) to empirical conformal p-values, then run BH-style FDR selection.

Weighted Conformal - Handle covariate shift scenarios where your test data comes from a different distribution than your training data. Essential for real-world deployment.

FDR Control - Deep dive into False Discovery Rate control. Understand when to use BH vs weighted methods and how to evaluate FDR performance.

Prerequisites

All examples assume you have installed nonconform with the PyOD and data extras:

pip install "nonconform[pyod,data]"

Most examples use the PyOD LOF detector and benchmark datasets from oddball. Each example is self-contained and can be run independently.