alibi_detect.saving.schemas module

Pydantic models used by validate_config() to validate configuration dictionaries. The resolved kwarg of validate_config() determines whether the unresolved or resolved pydantic models are used:

  • The unresolved models expect any artefacts specified within it to not yet have been resolved. The artefacts are still string references to local filepaths or registries (e.g. x_ref = ‘x_ref.npy’).

  • The resolved models expect all artefacts to be have been resolved into runtime objects. For example, x_ref should have been resolved into an np.ndarray.

Note

For detector pydantic models, the fields match the corresponding detector’s args/kwargs. Refer to the detector’s api docs for a full description of each arg/kwarg.

class alibi_detect.saving.schemas.CVMDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the CVMDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the CVMDrift documentation for a description of each field.

correction = 'bonferroni'
n_features = None
p_val = 0.05
preprocess_at_init = True
update_x_ref = None
class alibi_detect.saving.schemas.CVMDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the CVMDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the CVMDrift documentation for a description of each field.

correction = 'bonferroni'
n_features = None
p_val = 0.05
preprocess_at_init = True
update_x_ref = None
class alibi_detect.saving.schemas.CVMDriftOnlineConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the CVMDriftOnline detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the CVMDriftOnline documentation for a description of each field.

batch_size = 64
ert
n_bootstraps = 10000
n_features = None
verbose = True
window_sizes
class alibi_detect.saving.schemas.CVMDriftOnlineConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the CVMDriftOnline detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the CVMDriftOnline documentation for a description of each field.

batch_size = 64
ert
n_bootstraps = 10000
n_features = None
verbose = True
window_sizes
class alibi_detect.saving.schemas.ChiSquareDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the ChiSquareDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the ChiSquareDrift documentation for a description of each field.

categories_per_feature = None
correction = 'bonferroni'
n_features = None
p_val = 0.05
preprocess_at_init = True
update_x_ref = None
class alibi_detect.saving.schemas.ChiSquareDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the ChiSquareDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the ChiSquareDrift documentation for a description of each field.

categories_per_feature = None
correction = 'bonferroni'
n_features = None
p_val = 0.05
preprocess_at_init = True
update_x_ref = None
class alibi_detect.saving.schemas.ClassifierDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the ClassifierDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the ClassifierDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 32
binarize_preds = False
calibration_kwargs = None
dataloader = None
dataset = None
device = None
epochs = 3
learning_rate = 0.001
model
n_folds = None
optimizer = None
p_val = 0.05
preds_type = 'probs'
preprocess_at_init = True
preprocess_batch_fn = None
reg_loss_fn = None
retrain_from_scratch = True
seed = 0
train_kwargs = None
train_size = 0.75
update_x_ref = None
use_calibration = False
use_oob = False
verbose = 0
class alibi_detect.saving.schemas.ClassifierDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the ClassifierDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the ClassifierDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 32
binarize_preds = False
calibration_kwargs = None
dataloader = None
dataset = None
device = None
epochs = 3
learning_rate = 0.001
model = None
n_folds = None
optimizer = None
p_val = 0.05
preds_type = 'probs'
preprocess_at_init = True
preprocess_batch_fn = None
reg_loss_fn = None
retrain_from_scratch = True
seed = 0
train_kwargs = None
train_size = 0.75
update_x_ref = None
use_calibration = False
use_oob = False
verbose = 0
class alibi_detect.saving.schemas.ClassifierUncertaintyDriftConfig(*args, **kwargs)[source]

Bases: DetectorConfig

Unresolved schema for the ClassifierUncertaintyDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the ClassifierUncertaintyDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 32
data_type = None
device = None
input_shape = None
margin_width = 0.1
max_len = None
model
p_val = 0.05
preds_type = 'probs'
preprocess_batch_fn = None
tokenizer = None
uncertainty_type = 'entropy'
update_x_ref = None
x_ref
x_ref_preprocessed = False
class alibi_detect.saving.schemas.ClassifierUncertaintyDriftConfigResolved(*args, **kwargs)[source]

Bases: DetectorConfig

Resolved schema for the ClassifierUncertaintyDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the ClassifierUncertaintyDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 32
data_type = None
device = None
input_shape = None
margin_width = 0.1
max_len = None
model = None
p_val = 0.05
preds_type = 'probs'
preprocess_batch_fn = None
tokenizer = None
uncertainty_type = 'entropy'
update_x_ref = None
x_ref
x_ref_preprocessed = False
class alibi_detect.saving.schemas.ContextMMDDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the ContextMMDDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the ContextMMDDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 256
c_kernel = None
c_ref
device = None
n_folds = 5
n_permutations = 100
p_val = 0.05
preprocess_at_init = True
prop_c_held = 0.25
update_ref = None
verbose = False
x_kernel = None
class alibi_detect.saving.schemas.ContextMMDDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the MMDDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the MMDDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 256
c_kernel = None
c_ref
device = None
n_folds = 5
n_permutations = 100
p_val = 0.05
preprocess_at_init = True
prop_c_held = 0.25
update_ref = None
verbose = False
x_kernel = None
class alibi_detect.saving.schemas.CustomBaseModel(*args, **kwargs)[source]

Bases: BaseModel

Base pydantic model schema. The default pydantic settings are set here.

class Config[source]

Bases: object

arbitrary_types_allowed = True
extra = 'forbid'
class alibi_detect.saving.schemas.CustomBaseModelWithKwargs(*args, **kwargs)[source]

Bases: BaseModel

Base pydantic model schema. The default pydantic settings are set here.

class Config[source]

Bases: object

arbitrary_types_allowed = True
extra = 'allow'
class alibi_detect.saving.schemas.DeepKernelConfig(*args, **kwargs)[source]

Bases: CustomBaseModel

Unresolved schema for DeepKernel’s.

Examples

A DeepKernel, with a trainable GaussianRBF kernel applied to the projected inputs and a custom serialized kernel applied to the raw inputs:

[kernel]
eps = 0.01

[kernel.kernel_a]
src = "@utils.tensorflow.kernels.GaussianRBF"
trainable = true

[kernel.kernel_b]
src = "custom_kernel.dill"
sigma = [ 1.2,]
trainable = false

[kernel.proj]
src = "model/"
eps = 'trainable'

The proportion (in [0,1]) of weight to assign to the kernel applied to raw inputs. This can be either specified or set to ‘trainable’. Only relevant is kernel_b is not None.

kernel_a = '@utils.tensorflow.kernels.GaussianRBF'

The kernel to apply to the projected inputs. Defaults to a GaussianRBF with trainable bandwidth.

kernel_b = '@utils.tensorflow.kernels.GaussianRBF'

The kernel to apply to the raw inputs. Defaults to a GaussianRBF with trainable bandwidth. Set to None in order to use only the deep component (i.e. eps=0).

proj

The projection to be applied to the inputs before applying kernel_a. This should be a Tensorflow or PyTorch model, specified as an object registry reference, or a ModelConfig.

class alibi_detect.saving.schemas.DetectorConfig(*args, **kwargs)[source]

Bases: CustomBaseModel

Base detector config schema. Only fields universal across all detectors are defined here.

meta = None

Config metadata. Should not be edited.

name

Name of the detector e.g. MMDDrift.

class alibi_detect.saving.schemas.DriftDetectorConfig(*args, **kwargs)[source]

Bases: DetectorConfig

Unresolved base schema for drift detectors.

data_type = None

Specify data type added to the metadata. E.g. ‘tabular’`or `‘image’.

input_shape = None

Optionally pass the shape of the input data. Used when saving detectors.

preprocess_fn = None

Function to preprocess the data before computing the data drift metrics. A string referencing a serialized function in .dill format, an object registry reference, or a PreprocessConfig.

x_ref

Data used as reference distribution. Should be a string referencing a NumPy .npy file.

x_ref_preprocessed = False

Whether the given reference data x_ref has been preprocessed yet. If x_ref_preprocessed=True, only the test data x will be preprocessed at prediction time. If x_ref_preprocessed=False, the reference data will also be preprocessed.

class alibi_detect.saving.schemas.DriftDetectorConfigResolved(*args, **kwargs)[source]

Bases: DetectorConfig

Resolved base schema for drift detectors.

data_type = None

Specify data type added to the metadata. E.g. ‘tabular’ or ‘image’.

input_shape = None

Optionally pass the shape of the input data. Used when saving detectors.

preprocess_fn = None

Function to preprocess the data before computing the data drift metrics.

x_ref

Data used as reference distribution.

x_ref_preprocessed = False

Whether the given reference data x_ref has been preprocessed yet. If x_ref_preprocessed=True, only the test data x will be preprocessed at prediction time. If x_ref_preprocessed=False, the reference data will also be preprocessed.

class alibi_detect.saving.schemas.EmbeddingConfig(*args, **kwargs)[source]

Bases: CustomBaseModel

Unresolved schema for text embedding models. Currently, only pre-trained HuggingFace transformer models are supported.

Examples

Using the hidden states at the output of each layer of a TensorFlow BERT base model as text embeddings:

[embedding]
flavour = "tensorflow"
src = "bert-base-cased"
type = "hidden_state"
layers = [-1, -2, -3, -4, -5, -6, -7, -8]
flavour = 'tensorflow'

Whether the embedding model is a tensorflow or pytorch model.

layers = None

List specifying the hidden layers to be used to extract the embedding.

src

Model name e.g. “bert-base-cased”, or a filepath to directory storing the model to extract embeddings from (relative to the config.toml file, or absolute).

type

The type of embedding to be loaded. See embedding_type in TransformerEmbedding.

class alibi_detect.saving.schemas.FETDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the FETDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the FETDrift documentation for a description of each field.

alternative = 'two-sided'
correction = 'bonferroni'
n_features = None
p_val = 0.05
preprocess_at_init = True
update_x_ref = None
class alibi_detect.saving.schemas.FETDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the FETDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the FETDrift documentation for a description of each field.

alternative = 'two-sided'
correction = 'bonferroni'
n_features = None
p_val = 0.05
preprocess_at_init = True
update_x_ref = None
class alibi_detect.saving.schemas.FETDriftOnlineConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the FETDriftOnline detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the FETDriftOnline documentation for a description of each field.

alternative = 'greater'
ert
lam = 0.99
n_bootstraps = 10000
n_features = None
t_max = None
verbose = True
window_sizes
class alibi_detect.saving.schemas.FETDriftOnlineConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the FETDriftOnline detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the FETDriftOnline documentation for a description of each field.

alternative = 'greater'
ert
lam = 0.99
n_bootstraps = 10000
n_features = None
t_max = None
verbose = True
window_sizes
class alibi_detect.saving.schemas.KSDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the KSDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the KSDrift documentation for a description of each field.

alternative = 'two-sided'
correction = 'bonferroni'
n_features = None
p_val = 0.05
preprocess_at_init = True
update_x_ref = None
class alibi_detect.saving.schemas.KSDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the KSDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the KSDrift documentation for a description of each field. Resolved schema for the KSDrift detector.

alternative = 'two-sided'
correction = 'bonferroni'
n_features = None
p_val = 0.05
preprocess_at_init = True
update_x_ref = None
class alibi_detect.saving.schemas.KernelConfig(*args, **kwargs)[source]

Bases: CustomBaseModelWithKwargs

Unresolved schema for kernels, to be passed to a detector’s kernel kwarg.

If src specifies a GaussianRBF kernel, the sigma, trainable and init_sigma_fn fields are passed to it. Otherwise, all fields except src are passed as kwargs.

Examples

A GaussianRBF kernel, with three different bandwidths:

[kernel]
src = "@alibi_detect.utils.tensorflow.GaussianRBF"
trainable = false
sigma = [0.1, 0.2, 0.3]

A serialized kernel with keyword arguments passed:

[kernel]
src = "mykernel.dill"
sigma = 0.42
custom_setting = "xyz"
flavour

Whether the kernel is a tensorflow or pytorch kernel.

init_sigma_fn = None

Function used to compute the bandwidth sigma. Used when sigma is to be inferred. The function’s signature should match sigma_median(). If None, it is set to sigma_median().

sigma = None

Bandwidth used for the kernel. Needn’t be specified if being inferred or trained. Can pass multiple values to eval kernel with and then average.

src

A string referencing a filepath to a serialized kernel in .dill format, or an object registry reference.

trainable = False

Whether or not to track gradients w.r.t. sigma to allow it to be trained.

class alibi_detect.saving.schemas.LSDDDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the LSDDDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the LSDDDrift documentation for a description of each field.

backend = 'tensorflow'
device = None
lambda_rd_max = 0.2
n_kernel_centers = None
n_permutations = 100
p_val = 0.05
preprocess_at_init = True
sigma = None
update_x_ref = None
class alibi_detect.saving.schemas.LSDDDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the LSDDDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the LSDDDrift documentation for a description of each field.

backend = 'tensorflow'
device = None
lambda_rd_max = 0.2
n_kernel_centers = None
n_permutations = 100
p_val = 0.05
preprocess_at_init = True
sigma = None
update_x_ref = None
class alibi_detect.saving.schemas.LSDDDriftOnlineConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the LSDDDriftOnline detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the LSDDDriftOnline documentation for a description of each field.

backend = 'tensorflow'
device = None
ert
lambda_rd_max = 0.2
n_bootstraps = 1000
n_kernel_centers = None
sigma = None
verbose = True
window_size
class alibi_detect.saving.schemas.LSDDDriftOnlineConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the LSDDDriftOnline detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the LSDDDriftOnline documentation for a description of each field.

backend = 'tensorflow'
device = None
ert
lambda_rd_max = 0.2
n_bootstraps = 1000
n_kernel_centers = None
sigma = None
verbose = True
window_size
class alibi_detect.saving.schemas.LearnedKernelDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the LearnedKernelDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the LearnedKernelDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 32
batch_size_permutations = 1000000
batch_size_predict = 1000000
dataloader = None
dataset = None
device = None
epochs = 3
kernel
learning_rate = 0.001
n_permutations = 100
num_workers = 0
optimizer = None
p_val = 0.05
preprocess_at_init = True
preprocess_batch_fn = None
reg_loss_fn = None
retrain_from_scratch = True
train_kwargs = None
train_size = 0.75
update_x_ref = None
var_reg = 1e-05
verbose = 0
class alibi_detect.saving.schemas.LearnedKernelDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the LearnedKernelDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the LearnedKernelDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 32
batch_size_permutations = 1000000
batch_size_predict = 1000000
dataloader = None
dataset = None
device = None
epochs = 3
kernel = None
learning_rate = 0.001
n_permutations = 100
num_workers = 0
optimizer = None
p_val = 0.05
preprocess_at_init = True
preprocess_batch_fn = None
reg_loss_fn = None
retrain_from_scratch = True
train_kwargs = None
train_size = 0.75
update_x_ref = None
var_reg = 1e-05
verbose = 0
class alibi_detect.saving.schemas.MMDDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the MMDDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the MMDDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size_permutations = 1000000
configure_kernel_from_x_ref = True
device = None
kernel = None
n_permutations = 100
p_val = 0.05
preprocess_at_init = True
sigma = None
update_x_ref = None
class alibi_detect.saving.schemas.MMDDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the MMDDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the MMDDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size_permutations = 1000000
configure_kernel_from_x_ref = True
device = None
kernel = None
n_permutations = 100
p_val = 0.05
preprocess_at_init = True
sigma = None
update_x_ref = None
class alibi_detect.saving.schemas.MMDDriftOnlineConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the MMDDriftOnline detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the MMDDriftOnline documentation for a description of each field.

backend = 'tensorflow'
device = None
ert
kernel = None
n_bootstraps = 1000
sigma = None
verbose = True
window_size
class alibi_detect.saving.schemas.MMDDriftOnlineConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the MMDDriftOnline detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the MMDDriftOnline documentation for a description of each field.

backend = 'tensorflow'
device = None
ert
kernel = None
n_bootstraps = 1000
sigma = None
verbose = True
window_size
class alibi_detect.saving.schemas.MetaData(*args, **kwargs)[source]

Bases: CustomBaseModel

version
version_warning = False
class alibi_detect.saving.schemas.ModelConfig(*args, **kwargs)[source]

Bases: CustomBaseModel

Unresolved schema for (ML) models. Note that the model “backend” e.g. ‘tensorflow’, ‘pytorch’, ‘sklearn’, is set by backend in DetectorConfig.

Examples

A TensorFlow classifier model stored in the model/ directory, with the softmax layer extracted:

[model]
flavour = "tensorflow"
src = "model/"
layer = -1
custom_objects = None

Dictionary of custom objects. Passed to the tensorflow load_model function. This can be used to pass custom registered functions and classes to a model.

flavour

Whether the model is a tensorflow, pytorch or sklearn model. XGBoost models following the scikit-learn API are also included under sklearn.

layer = None

Optional index of hidden layer to extract. If not None, a HiddenOutput or HiddenOutput model is returned (dependent on flavour). Only applies to ‘tensorflow’ and ‘pytorch’ models.

src

Filepath to directory storing the model (relative to the config.toml file, or absolute). At present, TensorFlow models must be stored in H5 format.

class alibi_detect.saving.schemas.OptimizerConfig(*args, **kwargs)[source]

Bases: CustomBaseModelWithKwargs

Unresolved schema for optimizers. The optimizer dictionary has two possible formats:

1. A configuration dictionary compatible with tf.keras.optimizers.deserialize. For backend=’tensorflow’ only. 2. A dictionary containing only class_name, where this is a string referencing the optimizer name e.g. optimizer.class_name = ‘Adam’. In this case, the tensorflow or pytorch optimizer class of the same name is loaded. For backend=’tensorflow’ and backend=’pytorch’.

Examples

A TensorFlow Adam optimizer:

[optimizer]
class_name = "Adam"

[optimizer.config]
name = "Adam"
learning_rate = 0.001
decay = 0.0

A PyTorch Adam optimizer:

[optimizer]
class_name = "Adam"
class_name
config = None
class alibi_detect.saving.schemas.PreprocessConfig(*args, **kwargs)[source]

Bases: CustomBaseModel

Unresolved schema for drift detector preprocess functions, to be passed to a detector’s preprocess_fn kwarg. Once loaded, the function is wrapped in a partial(), to be evaluated within the detector.

If src specifies a generic Python function, the dictionary specified by kwargs is passed to it. Otherwise, if src specifies preprocess_drift() (src=’@cd.tensorflow.preprocess.preprocess_drift’), all fields (except kwargs) are passed to it.

Examples

Preprocessor with a model, text embedding and tokenizer passed to preprocess_drift():

[preprocess_fn]
src = "@cd.tensorflow.preprocess.preprocess_drift"
batch_size = 32
max_len = 100
tokenizer.src = "tokenizer/"  # TokenizerConfig

[preprocess_fn.model]
# ModelConfig
src = "model/"

[preprocess_fn.embedding]
# EmbeddingConfig
src = "embedding/"
type = "hidden_state"
layers = [-1, -2, -3, -4, -5, -6, -7, -8]

A serialized Python function with keyword arguments passed to it:

[preprocess_fn]
src = 'myfunction.dill'
kwargs = {'kwarg1'=0.7, 'kwarg2'=true}
batch_size = 10000000000

Batch size used during prediction.

device = None

Device type used. The default None tries to use the GPU and falls back on CPU if needed. Only relevant if src=’@cd.torch.preprocess.preprocess_drift’

dtype = 'np.float32'

Model output type, e.g. ‘tf.float32’

embedding = None

A text embedding model. Either a string referencing a HuggingFace transformer model name, an object registry reference, or a EmbeddingConfig. If model=None, the embedding is passed to preprocess_drift() as model. Otherwise, the model is chained to the output of the embedding as an additional preprocessing step.

kwargs = {}

Dictionary of keyword arguments to be passed to the function specified by src. Only used if src specifies a generic Python function.

max_len = None

Optional max token length for text drift.

model = None

Model used for preprocessing. Either an object registry reference, or a ModelConfig.

preprocess_batch_fn = None

Optional batch preprocessing function. For example to convert a list of objects to a batch which can be processed by the model.

src = '@cd.tensorflow.preprocess.preprocess_drift'

The preprocessing function. A string referencing a filepath to a serialized function in dill format, or an object registry reference.

tokenizer = None

Optional tokenizer for text drift. Either a string referencing a HuggingFace tokenizer model name, or a TokenizerConfig.

class alibi_detect.saving.schemas.RegressorUncertaintyDriftConfig(*args, **kwargs)[source]

Bases: DetectorConfig

Unresolved schema for the RegressorUncertaintyDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the RegressorUncertaintyDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 32
data_type = None
device = None
input_shape = None
max_len = None
model
n_evals = 25
p_val = 0.05
preprocess_batch_fn = None
tokenizer = None
uncertainty_type = 'mc_dropout'
update_x_ref = None
x_ref
x_ref_preprocessed = False
class alibi_detect.saving.schemas.RegressorUncertaintyDriftConfigResolved(*args, **kwargs)[source]

Bases: DetectorConfig

Resolved schema for the RegressorUncertaintyDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the RegressorUncertaintyDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 32
data_type = None
device = None
input_shape = None
max_len = None
model = None
n_evals = 25
p_val = 0.05
preprocess_batch_fn = None
tokenizer = None
uncertainty_type = 'mc_dropout'
update_x_ref = None
x_ref
x_ref_preprocessed = False
class alibi_detect.saving.schemas.SpotTheDiffDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the SpotTheDiffDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the SpotTheDiffDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 32
binarize_preds = False
dataloader = None
dataset = None
device = None
epochs = 3
initial_diffs = None
kernel = None
l1_reg = 0.01
learning_rate = 0.001
n_diffs = 1
n_folds = None
optimizer = None
p_val = 0.05
preprocess_batch_fn = None
retrain_from_scratch = True
seed = 0
train_kwargs = None
train_size = 0.75
verbose = 0
class alibi_detect.saving.schemas.SpotTheDiffDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the SpotTheDiffDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the SpotTheDiffDrift documentation for a description of each field.

backend = 'tensorflow'
batch_size = 32
binarize_preds = False
dataloader = None
dataset = None
device = None
epochs = 3
initial_diffs = None
kernel = None
l1_reg = 0.01
learning_rate = 0.001
n_diffs = 1
n_folds = None
optimizer = None
p_val = 0.05
preprocess_batch_fn = None
retrain_from_scratch = True
seed = 0
train_kwargs = None
train_size = 0.75
verbose = 0
class alibi_detect.saving.schemas.SupportedModel[source]

Bases: object

Pydantic custom type to check the model is one of the supported types (conditional on what optional deps are installed).

classmethod validate_model(model, values)[source]
Return type

Any

class alibi_detect.saving.schemas.SupportedOptimizer[source]

Bases: object

Pydantic custom type to check the optimizer is one of the supported types (conditional on what optional deps are installed).

classmethod validate_optimizer(optimizer, values)[source]
Return type

Any

class alibi_detect.saving.schemas.TabularDriftConfig(*args, **kwargs)[source]

Bases: DriftDetectorConfig

Unresolved schema for the TabularDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the TabularDrift documentation for a description of each field.

alternative = 'two-sided'
categories_per_feature = None
correction = 'bonferroni'
n_features = None
p_val = 0.05
preprocess_at_init = True
update_x_ref = None
class alibi_detect.saving.schemas.TabularDriftConfigResolved(*args, **kwargs)[source]

Bases: DriftDetectorConfigResolved

Resolved schema for the TabularDrift detector.

Except for the name and meta fields, the fields match the detector’s args and kwargs. Refer to the TabularDrift documentation for a description of each field.

alternative = 'two-sided'
categories_per_feature = None
correction = 'bonferroni'
n_features = None
p_val = 0.05
preprocess_at_init = True
update_x_ref = None
class alibi_detect.saving.schemas.TokenizerConfig(*args, **kwargs)[source]

Bases: CustomBaseModel

Unresolved schema for text tokenizers. Currently, only pre-trained HuggingFace tokenizer models are supported.

Examples

BERT base tokenizer with additional keyword arguments passed to the HuggingFace from_pretrained() method:

[tokenizer]
src = "bert-base-cased"

[tokenizer.kwargs]
use_fast = false
force_download = true
kwargs = {}

Dictionary of keyword arguments to pass to transformers.AutoTokenizer.from_pretrained().

src

Model name e.g. “bert-base-cased”, or a filepath to directory storing the tokenizer model (relative to the config.toml file, or absolute). Passed to passed to transformers.AutoTokenizer.from_pretrained().