anomaly_classification
anomaly_classification ¤
AnomalyClassificationEvents ¤
AnomalyClassificationEvents(
dataframe: DataFrame,
signal_uuid: str,
*,
event_uuid: str = "quality:anomaly_type",
value_column: str = "value_double",
time_column: str = "systime"
)
Bases: Base
Quality: Anomaly Classification
Classify anomalies in a numeric signal by type: spike, drift, oscillation, flatline, or level shift.
Methods: - classify_anomalies: Detect and classify anomalous windows. - detect_flatline: Signal stuck at constant value. - detect_oscillation: Periodic instability detection. - detect_drift: Short-term slope-based drift events.
detect_flatline ¤
detect_flatline(
min_duration: str = "1m", tolerance: float = 1e-06
) -> pd.DataFrame
Detect intervals where the signal is stuck at a constant value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_duration
|
str
|
Minimum duration to qualify as a flatline. |
'1m'
|
tolerance
|
float
|
Maximum std to consider as flat. |
1e-06
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: start_time, end_time, duration, stuck_value. |
detect_oscillation ¤
detect_oscillation(
window: str = "1m", min_crossings: int = 6
) -> pd.DataFrame
Detect windows with excessive zero-crossings of the detrended signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
str
|
Window size for analysis. |
'1m'
|
min_crossings
|
int
|
Minimum zero-crossings to flag oscillation. |
6
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: start_time, end_time, crossing_count, amplitude. |
detect_drift ¤
detect_drift(
window: str = "1h", min_slope: float = 0.01
) -> pd.DataFrame
Detect windows where the rolling slope exceeds a threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
str
|
Window size for slope computation. |
'1h'
|
min_slope
|
float
|
Minimum absolute slope to flag. |
0.01
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: start_time, end_time, slope, direction. |
classify_anomalies ¤
classify_anomalies(
window: str = "10m", z_threshold: float = 3.0
) -> pd.DataFrame
Detect anomalous windows and classify by type.
Types: spike, drift, oscillation, flatline, level_shift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
str
|
Window size for analysis. |
'10m'
|
z_threshold
|
float
|
Z-score threshold for spike detection. |
3.0
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: start_time, end_time, anomaly_type, severity, details. |