menelaus

menelaus.detector

class menelaus.detector.BatchDetector(*args, **kwargs)[source]

Bases: ABC

Abstract base class for all batch data-based detectors. Minimally implements abstract methods common to all batch based detection algorithms.

__init__(*args, **kwargs)[source]
abstract reset(*args, **kwargs)[source]

Initialize the detector’s drift state and other relevant attributes. Intended for use after drift_state == 'drift'.

abstract set_reference(X, y_true, y_pred)[source]

Initialize detector with a reference batch.

Parameters
  • X (pandas.DataFrame or numpy.array) – baseline dataset

  • y_true (numpy.array) – actual labels of dataset

  • y_pred (numpy.array) – predicted labels of dataset

abstract update(X, y_true, y_pred)[source]

Update detector with new batch of data

Parameters
  • X (numpy.ndarray) – input data

  • y_true (numpy.ndarray) – if applicable, true labels of input data

  • y_pred (numpy.ndarray) – if applicable, predicted labels of input data

property batches_since_reset

Number of batches since last drift detection.

Returns

int

property drift_state

Set detector’s drift state to "drift", "warning", or None.

property total_batches

Total number of batches the drift detector has been updated with.

Returns

int

class menelaus.detector.DriftDetector(*args, **kwargs)[source]

Bases: ABC

This class is deprecated in 0.2.0+.

Base class for Menelaus drift detectors.

A DriftDetector object implements the update and reset methods and calls the super methods to initialize and update the attributes below.

Generally, a DriftDetector is instantiated, then repeatedly passed new data via update. At each update step, its drift_state will reflect whether drift has been detected or almost been detected. After the detector’s state is set to "drift", update calls reset to re-initialize the relevant attributes.

A “batch” detector will compare a new dataset, passed via update, to a reference dataset, usually the original reference dataset. A “stream” detector compares only one new sample at a time, also passed via update.

__init__(*args, **kwargs)[source]
abstract reset(*args, **kwargs)[source]

Initialize the detector’s drift state and other relevant attributes. Intended for use after drift_state == 'drift'.

abstract update(X, y_true, y_pred)[source]

Update the detector with a new sample or batch.

Parameters
  • X (numpy.ndarray) – input data

  • y_true (numpy.ndarray) – if applicable, true labels of input data

  • y_pred (numpy.ndarray) – if applicable, predicted labels of input data

property drift_state

Detector’s current drift state, with values "drift", "warning",or None.

abstract property input_type

The type of input the detector accepts, either "batch", with multiple samples in one call to update(), or "stream", with one sample per call to update().

property total_updates

Number of samples/batches the drift detector has ever been updated with.

Returns

int

property updates_since_reset

Number of samples/batches since the last time the drift detector was reset.

Returns

int

class menelaus.detector.StreamingDetector(*args, **kwargs)[source]

Bases: ABC

Abstract base class for all streaming data-based detectors. Minimally implements abstract methods common to all stream based detection algorithms.

__init__(*args, **kwargs)[source]
abstract reset(*args, **kwargs)[source]

Initialize the detector’s drift state and other relevant attributes. Intended for use after drift_state == "drift".

abstract update(X, y_true, y_pred)[source]

Update detector with new sample (data point).

Parameters
  • X (numpy.ndarray) – if applicable, one row of features from input data

  • y_true (numpy.ndarray) – if applicable, one true label from input data

  • y_pred (numpy.ndarray) – if applicable, one predicted label from input data

property drift_state

Set detector’s drift state to "drift", "warning", or None.

property samples_since_reset

Number of samples since last drift detection.

Returns

int

property total_samples

Total number of samples the drift detector has been updated with.

Returns

int