How hiram64/ocsvm-anomaly-detection works
This repository is a small CIFAR-10-oriented unsupervised anomaly-detection workflow. CIFAR-10 batches are converted to labeled NPZ data; a convolutional autoencoder learns image representations and exports flattened encoded features; a one-class SVM is trained on the selected normal class and evaluated against sampled anomalies using ROC and PR AUC. The README also supports user-provided NPZ datasets in the same format. The main calls are visible in the sampled scripts; no additional runtime subsystems are evidenced.
Main entry points: cae.py CAE training runner · anomaly_detection_ocsvm.py OC-SVM evaluation · data Labeled image NPZ · make_cifar10_npz.py CIFAR NPZ builder
Components 10
Data preparation
- CIFAR NPZ builder
make_cifar10_npz.py - Labeled image NPZ
data
Feature learning
- CAE training runner
cae.py - Autoencoder model
model.py - Encoded feature NPZ
data
Anomaly detection
- OC-SVM evaluation
anomaly_detection_ocsvm.py - One-Class SVM
anomaly_detection_ocsvm.py - ROC and PR AUC
anomaly_detection_ocsvm.py
Other components
- Dataset user
- CIFAR-10 batches
Connections 11
- Dataset user → CIFAR-10 batches: provides
README.md - CIFAR-10 batches → CIFAR NPZ builder: input batches
make_cifar10_npz.py - CIFAR NPZ builder → Labeled image NPZ: writes images
make_cifar10_npz.py - Dataset user → Labeled image NPZ: may provide
README.md - Labeled image NPZ → CAE training runner: loads images
cae.py - CAE training runner → Autoencoder model: builds
cae.py - CAE training runner → Encoded feature NPZ: writes features
cae.py - CAE training runner → Encoded feature NPZ: exports labels
cae.py - Encoded feature NPZ → OC-SVM evaluation: loads features
anomaly_detection_ocsvm.py - OC-SVM evaluation → One-Class SVM: trains and scores
anomaly_detection_ocsvm.py - OC-SVM evaluation → ROC and PR AUC: calculates
anomaly_detection_ocsvm.py