ts_shape.events.maintenance.degradation_detection
| Name | Description |
|---|---|
DegradationDetectionEvents | Detect degradation patterns in time series signals: trend degradation, |
DegradationDetectionEvents
DegradationDetectionEvents(
dataframe: pd.DataFrame,
signal_uuid: str,
*,
event_uuid: str = "maint:degradation",
value_column: str = "value_double",
time_column: str = "systime"
) -> None
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.
| Name | Description |
|---|---|
detect_trend_degradation | Detect intervals where a rolling linear regression slope exceeds min_slope |
detect_variance_increase | Compare rolling variance against a baseline (first window) and flag |
detect_level_shift | CUSUM-like detection for permanent mean shifts in the signal. |
health_score | Composite 0-100 health score based on mean drift, variance change, |
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format timeseries frame (one row per sample, uuid identifies the signal). | required |
signal_uuid | str | UUID of the signal to analyze; must be present in dataframe. | required |
event_uuid | str | UUID stamped on emitted events. | 'maint:degradation' |
value_column | str | Column holding the signal values. | 'value_double' |
time_column | str | Timestamp column. | 'systime' |
detect_trend_degradation
detect_trend_degradation(
window: str = "1h",
min_slope: float = 0.0,
direction: str = "decreasing",
*,
interval_end: str = "next_change"
) -> pd.DataFrame
Detect intervals where a rolling linear regression slope exceeds min_slope in the given direction, indicating trend-based degradation.
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Rolling window size (e.g. '1h', '30min'). | '1h' |
min_slope | float | Minimum absolute slope to consider degradation. | 0.0 |
direction | str | 'decreasing' (negative slope) or 'increasing' (positive slope). | 'decreasing' |
interval_end | str | "next_change" (default) ends an interval at the next sample (the transition), so the interval spans the time the condition held and change-encoded signals -- one row per change -- keep their duration. "last_sample" ends it at its last flagged sample. See :func:ts_shape.utils.intervals.interval_end_times. | 'next_change' |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, uuid, source_uuid, is_delta, |
DataFrame | avg_slope, total_change, duration_seconds. source_uuid is the |
DataFrame | analyzed signal. |
detect_variance_increase
detect_variance_increase(
window: str = "1h",
threshold_factor: float = 2.0,
*,
interval_end: str = "next_change"
) -> pd.DataFrame
Compare rolling variance against a baseline (first window) and flag intervals where the ratio exceeds threshold_factor.
The baseline is [first sample, first sample + window), the same
number of samples as each rolling (t - window, t] window of a
regular signal, so a stationary signal has ratio 1. Samples inside
the baseline window are not flagged (their rolling windows are the
partial warm-up of the baseline).
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Rolling window size. | '1h' |
threshold_factor | float | Minimum variance ratio to flag. | 2.0 |
interval_end | str | "next_change" (default) ends an interval at the next sample (the transition), so the interval spans the time the condition held and change-encoded signals -- one row per change -- keep their duration. "last_sample" ends it at its last flagged sample. See :func:ts_shape.utils.intervals.interval_end_times. | 'next_change' |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, uuid, source_uuid, is_delta, |
DataFrame | baseline_variance, current_variance, ratio, duration_seconds |
DataFrame | (float seconds from start to end). |
detect_level_shift
detect_level_shift(min_shift: float, hold: str = '5min') -> pd.DataFrame
CUSUM-like detection for permanent mean shifts in the signal.
| Name | Type | Description | Default |
|---|---|---|---|
min_shift | float | Minimum absolute shift magnitude to detect. | required |
hold | str | Minimum duration the new level must persist. | '5min' |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: systime, uuid, source_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.
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Rolling window for current metrics. | '1h' |
baseline_window | str | Initial period used to establish baseline behavior: first sample, first sample + baseline_window), half-open like the rolling windows. | '24h' |
| Type | Description |
|---|---|
[DataFrame | DataFrame with columns: systime, uuid, source_uuid, is_delta, |
DataFrame | health_score, mean_drift_pct, variance_ratio, variance_factor |
DataFrame | (current / baseline variance; above 1 when the variance grew), |
DataFrame | trend_slope. |
DataFrame | Canonical twin columns: variance_factor (after |
DataFrame | variance_ratio, which is not a 0-1 fraction); it holds the |
DataFrame | same values as the deprecated column right before it, which is |
DataFrame | removed in the next major release. |