Skip to main content
Version: Next

ts_shape.events.engineering.time_to_threshold

Classes
NameDescription
TimeToThresholdEventsEngineering: Time-to-Threshold Prediction

TimeToThresholdEvents​

classsource
TimeToThresholdEvents(
dataframe: pd.DataFrame,
signal_uuid: str,
*,
event_uuid: str = "eng:time_to_threshold",
value_column: str = "value_double",
time_column: str = "systime"
) -> None

Bases: Base

Engineering: Time-to-Threshold Prediction

Answer the question "when will this signal hit X at the current rate?" by extrapolating recent trends. Complements :class:ThresholdMonitoringEvents (which detects when you crossed a threshold) with predictive analysis.

Methods:

  • time_to_threshold: Estimate time until the signal reaches a value.
  • time_to_threshold_windows: Per-window time-to-threshold estimates.
  • remaining_useful_range: Time until signal leaves an acceptable band.
  • crossing_forecast: Forecast crossing times for multiple thresholds.
Functions
NameDescription
time_to_thresholdEstimate time until the signal reaches a threshold value.
time_to_threshold_windowsPer-window time-to-threshold estimates.
remaining_useful_rangeEstimate time until the signal leaves an acceptable operating band.
crossing_forecastForecast crossing times for multiple named thresholds.
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.'eng:time_to_threshold'
value_columnstrColumn holding the signal values.'value_double'
time_columnstrTimestamp column.'systime'

time_to_threshold​

methodsource
time_to_threshold(
threshold: float, lookback: str = "1h", direction: str = "auto"
) -> pd.DataFrame

Estimate time until the signal reaches a threshold value.

Fits a linear trend to the most recent lookback window and extrapolates to find when the threshold would be crossed.

Parameters
NameTypeDescriptionDefault
thresholdfloatTarget value to predict crossing time for.required
lookbackstrHow far back to look for trend estimation.'1h'
directionstr'rising', 'falling', or 'auto' (infer from slope sign).'auto'
Returns
TypeDescription
DataFrameSingle-row DataFrame with columns: current_value, slope_per_second,
DataFramethreshold, estimated_seconds, estimated_time, confidence,
DataFramedirection.

time_to_threshold_windows​

methodsource
time_to_threshold_windows(
threshold: float, window: str = "1h", lookback: str = "1h"
) -> pd.DataFrame

Per-window time-to-threshold estimates.

For each window, fits a trend to the preceding lookback period and estimates when the threshold will be crossed.

Parameters
NameTypeDescriptionDefault
thresholdfloatTarget value.required
windowstrAnalysis window frequency.'1h'
lookbackstrLookback period for trend estimation.'1h'
Returns
TypeDescription
DataFrameSummary DataFrame with columns: start, end, duration_seconds
DataFrame(the window bounds), window_start (the resample label; a
DataFramedeprecated twin of start), current_value,
DataFrameslope_per_second, estimated_seconds, confidence, direction.

remaining_useful_range​

methodsource
remaining_useful_range(
lower_limit: float, upper_limit: float, lookback: str = "1h"
) -> pd.DataFrame

Estimate time until the signal leaves an acceptable operating band.

Parameters
NameTypeDescriptionDefault
lower_limitfloatLower acceptable limit.required
upper_limitfloatUpper acceptable limit.required
lookbackstrLookback period for trend estimation.'1h'
Returns
TypeDescription
DataFrameSingle-row DataFrame with columns: current_value,
DataFrameslope_per_second, nearest_bound, nearest_bound_value,
DataFrameestimated_seconds, estimated_time, confidence.

crossing_forecast​

methodsource
crossing_forecast(
thresholds: dict[str, float], lookback: str = "1h"
) -> pd.DataFrame

Forecast crossing times for multiple named thresholds.

Parameters
NameTypeDescriptionDefault
thresholdsdict[str, float]Dict mapping names to values, e.g. {'warning': 80, 'alarm': 90, 'critical': 95}.required
lookbackstrLookback period for trend estimation.'1h'
Returns
TypeDescription
DataFrameDataFrame with columns: threshold_name, threshold_value,
DataFrameestimated_seconds, estimated_time, reachable.