alibi_detect.cd.base_online module

class alibi_detect.cd.base_online.BaseDriftOnline(x_ref, ert, window_size, preprocess_fn=None, n_bootstraps=1000, verbose=True, input_shape=None, data_type=None)[source]

Bases: alibi_detect.base.BaseDetector

__init__(x_ref, ert, window_size, preprocess_fn=None, n_bootstraps=1000, verbose=True, input_shape=None, data_type=None)[source]

Base class for online drift detectors.

Parameters
  • x_ref (Union[ndarray, list]) – Data used as reference distribution.

  • ert (float) – The expected run-time (ERT) in the absence of drift.

  • window_size (int) – The size of the sliding test-window used to compute the test-statistic. Smaller windows focus on responding quickly to severe drift, larger windows focus on ability to detect slight drift.

  • preprocess_fn (Optional[Callable]) – Function to preprocess the data before computing the data drift metrics.

  • n_bootstraps (int) – The number of bootstrap simulations used to configure the thresholds. The larger this is the more accurately the desired ERT will be targeted. Should ideally be at least an order of magnitude larger than the ert.

  • verbose (bool) – Whether or not to print progress during configuration.

  • input_shape (Optional[tuple]) – Shape of input data.

  • data_type (Optional[str]) – Optionally specify the data type (tabular, image or time-series). Added to metadata.

Return type

None

get_threshold(t)[source]
Return type

Optional[float]

predict(x_t, return_test_stat=True)[source]

Predict whether the most recent window of data has drifted from the reference data.

Parameters
  • x_t (Union[ndarray, Any]) – A single instance to be added to the test-window.

  • return_test_stat (bool) – Whether to return the test statistic and threshold.

Return type

Dict[Dict[str, str], Dict[str, Union[int, float]]]

Returns

  • Dictionary containing ‘meta’ and ‘data’ dictionaries.

  • ’meta’ has the model’s metadata.

  • ’data’ contains the drift prediction and optionally the test-statistic and threshold.

reset()[source]

Resets the detector but does not reconfigure thresholds.

Return type

None