AnomalyClassificationEvents¤
Classify anomalies in a numeric signal by type: spike, drift, oscillation, flatline, or level shift.
Module: ts_shape.events.quality.anomaly_classification
Guide: Quality Control & SPC
When to Use¤
Use after initial anomaly detection to understand the nature of anomalies. Goes beyond "is this an outlier?" to tell you what kind of anomaly it is, enabling targeted corrective action. Works best when combined with an upstream outlier detection step to narrow the signal regions of interest.
Quick Example¤
from ts_shape.events.quality.anomaly_classification import AnomalyClassificationEvents
classifier = AnomalyClassificationEvents(df, value_column="value_double")
# Full multi-type classification in one pass
classified = classifier.classify_anomalies(window="10m", z_threshold=3.0)
# Or detect specific anomaly types individually
flatlines = classifier.detect_flatline(min_duration="1m", tolerance=1e-6)
oscillations = classifier.detect_oscillation(window="1m", min_crossings=6)
drifts = classifier.detect_drift(window="1h", min_slope=0.01)
Key Methods¤
| Method | Purpose | Returns |
|---|---|---|
detect_flatline(min_duration='1m', tolerance=1e-6) |
Detect stuck/frozen signal segments | DataFrame with flatline event intervals |
detect_oscillation(window='1m', min_crossings=6) |
Detect excessive oscillation (e.g., control valve hunting) | DataFrame with oscillation flags |
detect_drift(window='1h', min_slope=0.01) |
Detect gradual drift in signal mean | DataFrame with drift events |
classify_anomalies(window='10m', z_threshold=3.0) |
Multi-type classification: spike, drift, oscillation, flatline, level shift | DataFrame with anomaly type labels |
Tips & Notes¤
Run outlier detection first, then classify
Use OutlierDetectionEvents to flag anomalous regions, then pass those regions to classify_anomalies() for root-cause identification. This two-step approach reduces false positives and makes classification more meaningful.
Related modules
- Outlier Detection — detect anomalies before classifying them
- Sensor Drift — specialized drift detection for calibration monitoring
- Signal Quality — distinguish data quality issues from true process anomalies
See Also¤
- Quality Control & SPC Guide — narrative overview
- API Reference — full parameter docs