Out-of-Distribution VAEGMM

How-To Guides

Check out this how to to begin using the Out-of-Distribution Detection class

Out-of-Distribution Detection Tutorial

DataEval API

class dataeval.detectors.OOD_VAEGMM(model: VAEGMM, samples: int = 10)
fit(x_ref: ~numpy._typing._array_like._SupportsArray[~numpy.dtype[~typing.Any]] | ~numpy._typing._nested_sequence._NestedSequence[~numpy._typing._array_like._SupportsArray[~numpy.dtype[~typing.Any]]] | bool | int | float | complex | str | bytes | ~numpy._typing._nested_sequence._NestedSequence[bool | int | float | complex | str | bytes], threshold_perc: float = 100.0, loss_fn: ~typing.Callable = <dataeval.models.tensorflow.LossGMM object>, optimizer: ~keras.src.optimizers.optimizer.Optimizer = <class 'keras.src.optimizers.adam.Adam'>, epochs: int = 20, batch_size: int = 64, verbose: bool = True) None

Train the AE model with recommended loss function and optimizer.

Parameters:
  • X (ArrayLike) – Training batch.

  • threshold_perc (float, default 100.0) – Percentage of reference data that is normal.

  • loss_fn (Callable, default LossGMM(elbo=Elbo(0.05))) – Loss function used for training.

  • optimizer (keras.optimizers.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.

predict(X: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], batch_size: int = 10000000000, ood_type: Literal['feature', 'instance'] = 'instance') Dict[str, ndarray]

Predict whether instances are out-of-distribution or not.

Parameters:
  • X (ArrayLike) – Batch of instances.

  • batch_size (int, default int(1e10)) – Batch size used when making predictions with the autoencoder.

  • ood_type (Literal["feature", "instance"], default "instance") – Predict out-of-distribution at the ‘feature’ or ‘instance’ level.

Return type:

Dictionary containing the outlier predictions and both feature and instance level outlier scores.

score(X: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], batch_size: int = 10000000000) OODScore

Compute instance and (optionally) feature level outlier scores.

Parameters:
  • X (ArrayLike) – Batch of instances.

  • batch_size (int, default int(1e10)) – Batch size used when making predictions with the autoencoder.

Return type:

Instance and feature level outlier scores.