Triggers

PREDICT.Triggers.SPCTrigger(model, input_data, dateCol='date', clStartDate=None, clEndDate=None, numMonths=None, warningCL=None, recalCL=None, warningSDs=2, recalSDs=3, verbose=True)
Trigger function to update the model if the error enters an upper control limit.

The control limits can be set using one of the following methods:

  • Enter a start (clStartDate) and end date (clEndDate) to determine the control limits using the error mean and std during this period.

  • Enter the number of months (numMonths) to base the control limits on from the start of the period.

  • Manually set the control limits by entering the float values for the ‘warning’ (warningCL) and ‘recalibration’ (recalCL) zones.

  • Enter the number of standard deviations from the mean for the start of the warning zone (warningSDs) and the start of the recalibration zone (recalSDs).

Parameters:
  • model (PREDICTModel) – The model to evaluate, must have a predict method.

  • input_data (dataframe) – DataFrame with column of the predicted outcome.

  • dateCol (str) – Column containing the dates.

  • clStartDate (str) – Start date to determine control limits from. Defaults to None.

  • clEndDate (str) – End date to determine control limits from. Defaults to None.

  • numMonths (int) – The number of months to base the control limits on. Defaults to None.

  • warningCL (float) – A manually set control limit for the warning control limit. Defaults to None.

  • recalCL (float) – A manually set control limit for the recalibration trigger limit. Defaults to None.

  • warningSDs (int or float) – Number of standard deviations from the mean to set the warning limit to. Defaults to 2.

  • recalSDs (int or float) – Number of standard deviations from the mean to set the recalibration trigger to. Defaults to 3.

  • verbose (bool) – If True, prints the control limit warnings. Defaults to True.

Returns:

A tuple containing:

  • pd.Timedelta: The calculated time interval for updating the model.

  • pd.DatetimeIndex: A range of dates specifying the update schedule.

Return type:

tuple

PREDICT.Triggers.TimeframeTrigger(model, updateTimestep, dataStart, dataEnd)

Create a list of dates to update the model based on a fixed time interval.

Parameters:
  • model (PREDICTModel) – The model to evaluate, must have a predict method.

  • updateTimestep (pd.Timedelta) – Time interval at which to update the model. Note: The model can only be recalibrated at the end of the time interval. If the prediction window is less than the updateTimestep, the model will not be recalibrated.

  • dataStart (pd.Timedelta) – Date of when to start regular recalibration.

  • dataEnd (pd.Timedelta) – Date of when to end regular recalibration.

Raises:

TypeError – If updateTimestep is not a valid input.

Returns:

A tuple containing:

  • pd.Timedelta: The calculated time interval for updating the model.

  • pd.DatetimeIndex: A range of dates specifying the update schedule, excluding the first window.

Return type:

tuple