alibi_detect.cd.utils module

alibi_detect.cd.utils.encompass_batching(model, backend, batch_size, device=None, tokenizer=None, max_len=None)[source]

Takes a function that must be batch evaluated (on tokenized input) and returns a function that handles batching (and tokenization).

Return type

Callable

alibi_detect.cd.utils.encompass_shuffling_and_batch_filling(model_fn, batch_size)[source]

Takes a function that already handles batching but additionally performing shuffling and ensures instances are evaluated as part of full batches.

Return type

ndarray

alibi_detect.cd.utils.update_reference(X_ref, X, n, update_method=None)[source]

Update reference dataset for drift detectors.

Parameters
  • X_ref (ndarray) – Current reference dataset.

  • X (ndarray) – New data.

  • n (int) – Count of the total number of instances that have been used so far.

  • update_method (Optional[Dict[str, int]]) – Dict with as key reservoir_sampling or last and as value n. reservoir_sampling will apply reservoir sampling with reservoir of size n while last will return (at most) the last n instances.

Return type

ndarray

Returns

Updated reference dataset.