alibi_detect.utils.prediction module

alibi_detect.utils.prediction.predict_batch(model, X, batch_size=10000000000, proba=False, return_class=False, n_categories=None, shape=None, dtype=numpy.float32)[source]

Make batch predictions on a model.

Parameters
  • model (Union[Model, Callable, AE, AEGMM, Seq2Seq, VAE, VAEGMM]) – tf.keras model or one of the other permitted types defined in Data.

  • X (ndarray) – Batch of instances.

  • batch_size (int) – Batch size used during prediction.

  • proba (bool) – Whether to return model prediction probabilities.

  • return_class (bool) – Whether to return model class predictions.

  • n_categories (Optional[int]) – Number of prediction categories. Can also be inferred from the model.

  • shape (Optional[tuple]) – Optional shape or tuple with shapes of the model predictions.

  • dtype (type) – Output type.

Return type

Union[ndarray, tuple]

Returns

Numpy array with predictions.

alibi_detect.utils.prediction.predict_batch_transformer(model, tokenizer, X, max_len, batch_size=10000000000)[source]
Parameters
  • model (Model) – HuggingFace transformer model.

  • tokenizer – Tokenizer for model.

  • X (ndarray) – Batch of instances.

  • max_len (int) – Max token length.

  • batch_size (int) – Batch size.

Return type

ndarray

Returns

Numpy array with predictions.