Digits one-class anomaly detection¶
The digits example is intentionally visual and easy to understand: train on one digit and treat another digit as the anomaly. It is a compact test of one-class feature geometry.
Result at a glance¶
FastMCD ties EllipticEnvelope at F1=0.900 and has ROC-AUC around 0.987. IsolationForest, LOF, and OneClassSVM are lower in this setup.
What the data represent¶
The example uses sklearn digits features with digit 0 as the normal class and digit 1 as the anomaly class in the captured run.
Why this estimator¶
FastMCD is appropriate because the normal digit features form a compact central group after preprocessing.
Reproduce the result¶
python examples/use_case_digits_one_class_baselines.py
Output from the run¶
digits one-class anomaly detection
method,seconds,precision,recall,f1,roc_auc,detected
sklearn EllipticEnvelope,0.0397,0.9000,0.9000,0.9000,0.9908,30
robustcov FastMCD,0.0443,0.9000,0.9000,0.9000,0.9871,30
sklearn IsolationForest,0.1331,0.7333,0.7333,0.7333,0.9502,30
sklearn LocalOutlierFactor,0.0027,0.5333,0.5333,0.5333,0.8672,30
sklearn OneClassSVM,0.0020,0.4375,0.4667,0.4516,0.8687,32
normal_digit=0, anomaly_digit=1, anomaly_count=30, n=208, p=12
anomaly_fraction=0.144, robust_radial_kurtosis=120.197
saved diagnostics to results/use_cases/digits_one_class
Figures and diagnostics¶
How to read the result¶
The score profile shows whether anomaly digits are concentrated at the top of the robust-distance ranking. This is often more informative than a single threshold.
What this does not prove¶
If several digits or styles are valid normal data, a cluster-aware detector is usually more appropriate than one global covariance model.