Skip to content

failure_prediction

failure_prediction ¤

FailurePredictionEvents ¤

FailurePredictionEvents(
    dataframe: DataFrame,
    signal_uuid: str,
    *,
    event_uuid: str = "maint:failure_pred",
    value_column: str = "value_double",
    time_column: str = "systime"
)

Bases: Base

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

remaining_useful_life ¤

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:

Name Type Description Default
degradation_rate float

Expected rate of change per second (used as fallback if local slope cannot be computed).

required
failure_threshold float

The 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:

Type Description
DataFrame

DataFrame with columns: systime, uuid, source_uuid, is_delta,

DataFrame

current_value, rul_seconds, rul_hours, confidence. rul_* is 0 once the

DataFrame

threshold is reached or passed, and None when no failure is

DataFrame

projected (flat trend, or a trend moving away from the threshold).

detect_exceedance_pattern ¤

detect_exceedance_pattern(
    warning_threshold: float,
    critical_threshold: float,
    window: str = "1h",
) -> pd.DataFrame

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

Parameters:

Name Type Description Default
warning_threshold float

Warning level (absolute value comparison).

required
critical_threshold float

Critical level (absolute value comparison).

required
window str

Rolling window size.

'1h'

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, duration_seconds, uuid,

DataFrame

source_uuid, is_delta, warning_count, critical_count,

DataFrame

escalation_detected. end is start plus window.

time_to_threshold ¤

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

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

Parameters:

Name Type Description Default
threshold float

Target threshold value.

required
direction str

'increasing' or 'decreasing'.

'increasing'

Returns:

Type Description
DataFrame

DataFrame with columns: systime, uuid, source_uuid, is_delta,

DataFrame

current_value, rate_of_change, estimated_time_seconds.