Skip to main content
Version: Next

ts_shape.events.maintenance.failure_prediction

Classes
NameDescription
FailurePredictionEventsPredict remaining useful life and detect escalating failure patterns

FailurePredictionEvents​

classsource
FailurePredictionEvents(
dataframe: pd.DataFrame,
signal_uuid: str,
*,
event_uuid: str = "maint:failure_pred",
value_column: str = "value_double",
time_column: str = "systime"
) -> None

Bases: Base

Predict remaining useful life and detect escalating failure patterns in time series signals from manufacturing/industrial IoT systems.

Functions
NameDescription
remaining_useful_lifeEstimate remaining useful life (RUL) at each point via linear
detect_exceedance_patternTrack frequency of threshold exceedances in rolling windows and
time_to_thresholdEstimate time to reach a threshold based on recent rate of change.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format timeseries frame (one row per sample, uuid identifies the signal).required
signal_uuidstrUUID of the signal to analyze.required
event_uuidstrUUID stamped on emitted events.'maint:failure_pred'
value_columnstrColumn holding the signal values.'value_double'
time_columnstrTimestamp column.'systime'

remaining_useful_life​

methodsource
remaining_useful_life(
degradation_rate: float, failure_threshold: float
) -> pd.DataFrame

Estimate remaining useful life (RUL) at each point via linear extrapolation from the recent trend to a failure threshold.

Parameters
NameTypeDescriptionDefault
degradation_ratefloatExpected rate of change per second (used as fallback if local slope cannot be computed).required
failure_thresholdfloatThe signal level that represents failure. The sign of degradation_rate gives the failure direction (positive: failure when the value rises to the threshold).required
Returns
TypeDescription
DataFrameDataFrame with columns: systime, uuid, source_uuid, is_delta,
DataFramecurrent_value, rul_seconds, rul_hours, confidence. rul_* is 0 once the
DataFramethreshold is reached or passed, and None when no failure is
DataFrameprojected (flat trend, or a trend moving away from the threshold).

detect_exceedance_pattern​

methodsource
detect_exceedance_pattern(
warning_threshold: float,
critical_threshold: float,
window: str = "1h",
*,
direction: str | None = None
) -> pd.DataFrame

Track frequency of threshold exceedances in rolling windows and flag escalating patterns (increasing exceedance counts).

Parameters
NameTypeDescriptionDefault
warning_thresholdfloatWarning level (absolute value comparison).required
critical_thresholdfloatCritical level (absolute value comparison).required
windowstrRolling window size.'1h'
directionstr | None"rising" (failure at high values) or "falling" (at low values). Given, a critical level that is not beyond the warning level raises ValueError (swapped levels). None (default) infers it from the order of the two levels (critical >= warning: rising).None
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid,
DataFramesource_uuid, is_delta, warning_count, critical_count,
DataFrameescalation_detected. end is start plus window.

time_to_threshold​

methodsource
time_to_threshold(
threshold: float, direction: str = "increasing"
) -> pd.DataFrame

Estimate time to reach a threshold based on recent rate of change.

Parameters
NameTypeDescriptionDefault
thresholdfloatTarget threshold value.required
directionstr'increasing' or 'decreasing'.'increasing'
Returns
TypeDescription
DataFrameDataFrame with columns: systime, uuid, source_uuid, is_delta,
DataFramecurrent_value, rate_of_change, estimated_time_seconds.