degradation_detection
degradation_detection ¤
DegradationDetectionEvents ¤
DegradationDetectionEvents(
dataframe: DataFrame,
signal_uuid: str,
*,
event_uuid: str = "maint:degradation",
value_column: str = "value_double",
time_column: str = "systime"
)
Bases: Base
Detect degradation patterns in time series signals: trend degradation, variance increases, level shifts, and composite health scores.
Designed for predictive maintenance on manufacturing/industrial IoT data.
detect_trend_degradation ¤
detect_trend_degradation(
window: str = "1h",
min_slope: float = 0.0,
direction: str = "decreasing",
) -> pd.DataFrame
Detect intervals where a rolling linear regression slope exceeds min_slope in the given direction, indicating trend-based degradation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
str
|
Rolling window size (e.g. '1h', '30m'). |
'1h'
|
min_slope
|
float
|
Minimum absolute slope to consider degradation. |
0.0
|
direction
|
str
|
'decreasing' (negative slope) or 'increasing' (positive slope). |
'decreasing'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: start, end, uuid, is_delta, avg_slope, |
DataFrame
|
total_change, duration_seconds. |
detect_variance_increase ¤
detect_variance_increase(
window: str = "1h", threshold_factor: float = 2.0
) -> pd.DataFrame
Compare rolling variance against a baseline (first window) and flag intervals where the ratio exceeds threshold_factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
str
|
Rolling window size. |
'1h'
|
threshold_factor
|
float
|
Minimum variance ratio to flag. |
2.0
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: start, end, uuid, is_delta, |
DataFrame
|
baseline_variance, current_variance, ratio. |
detect_level_shift ¤
detect_level_shift(
min_shift: float, hold: str = "5m"
) -> pd.DataFrame
CUSUM-like detection for permanent mean shifts in the signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_shift
|
float
|
Minimum absolute shift magnitude to detect. |
required |
hold
|
str
|
Minimum duration the new level must persist. |
'5m'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: systime, uuid, is_delta, |
DataFrame
|
shift_magnitude, prev_mean, new_mean. |
health_score ¤
health_score(
window: str = "1h", baseline_window: str = "24h"
) -> pd.DataFrame
Composite 0-100 health score based on mean drift, variance change, and trend slope, computed over rolling windows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
str
|
Rolling window for current metrics. |
'1h'
|
baseline_window
|
str
|
Initial period used to establish baseline behaviour. |
'24h'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: systime, uuid, is_delta, |
DataFrame
|
health_score, mean_drift_pct, variance_ratio, trend_slope. |