dataeval.detectors.ood.OOD_AE¶
-
class dataeval.detectors.ood.OOD_AE(model, device=
None)¶ Autoencoder based out-of-distribution detector.
- Parameters:¶
Example
Perform out-of-distribution detection on test data.
>>> from dataeval.utils.torch.models import AE>>> input_shape = train_images[0].shape >>> ood = OOD_AE(AE(input_shape))Train the autoencoder using the training data.
>>> ood.fit(train_images, threshold_perc=99, epochs=20)Test for out-of-distribution samples on the test data.
>>> output = ood.predict(test_images) >>> output.is_ood array([ True, True, False, True, True, True, True, True])-
fit(x_ref, threshold_perc, loss_fn=
None, optimizer=None, epochs=20, batch_size=64, verbose=False)¶ Train the model and infer the threshold value.
- Parameters:¶
- x_ref : ArrayLike¶
Training data.
- threshold_perc : float, default 100.0¶
Percentage of reference data that is normal.
- loss_fn : Callable | None, default None¶
Loss function used for training.
- optimizer : Optimizer, default keras.optimizers.Adam¶
Optimizer used for training.
- epochs : int, default 20¶
Number of training epochs.
- batch_size : int, default 64¶
Batch size used for training.
- verbose : bool, default True¶
Whether to print training progress.
- Return type:¶
None
-
predict(X, batch_size=
int(10000000000.0), ood_type='instance')¶ Predict whether instances are out of distribution or not.
-
score(X, batch_size=
int(10000000000.0))¶ Compute the out of distribution scores for a given dataset.