alibi_detect.od.pytorch.ensemble module
- class alibi_detect.od.pytorch.ensemble.AverageAggregator(weights=None)[source]
Bases:
BaseTransformTorch
- __init__(weights=None)[source]
Averages the scores of the detectors in an ensemble.
- Parameters:
weights (
Optional
[Tensor
]) – Optional parameter to weight the scores. If weights is leftNone
then will be set to a vector of ones.- Raises:
ValueError – If weights does not sum to
1
.
- transform(scores)[source]
Averages the scores of the detectors in an ensemble. If weights were passed in the __init__ then these are used to weight the scores.
- Parameters:
scores (
Tensor
) – Torch.Tensor of scores from ensemble of detectors.- Return type:
Tensor
- Returns:
Torch.Tensor of mean of scores.
- class alibi_detect.od.pytorch.ensemble.BaseTransformTorch(*args: Any, **kwargs: Any)[source]
Bases:
Module
- class alibi_detect.od.pytorch.ensemble.Ensembler(normalizer=None, aggregator=None)[source]
Bases:
BaseTransformTorch
,FitMixinTorch
- __init__(normalizer=None, aggregator=None)[source]
An Ensembler applies normalization and aggregation operations to the scores of an ensemble of detectors.
- Parameters:
normalizer (
Optional
[BaseTransformTorch
]) – BaseFittedTransformTorch object to normalize the scores. IfNone
then no normalization is applied.aggregator (
Optional
[BaseTransformTorch
]) – BaseTransformTorch object to aggregate the scores. IfNone
defaults to AverageAggregator.
- class alibi_detect.od.pytorch.ensemble.FitMixinTorch[source]
Bases:
ABC
- check_fitted()[source]
Checks to make sure object has been fitted.
- Raises:
NotFittedError – Raised if method called and object has not been fit.
- abstract fit(x_ref)[source]
Abstract fit method.
- Parameters:
x – torch.Tensor to fit object on.
- Return type:
Self
- fitted = False
- class alibi_detect.od.pytorch.ensemble.MaxAggregator(*args: Any, **kwargs: Any)[source]
Bases:
BaseTransformTorch
- class alibi_detect.od.pytorch.ensemble.MinAggregator(*args: Any, **kwargs: Any)[source]
Bases:
BaseTransformTorch
- class alibi_detect.od.pytorch.ensemble.PValNormalizer(*args: Any, **kwargs: Any)[source]
Bases:
BaseTransformTorch
,FitMixinTorch
- __init__()[source]
Maps scores to there p-values.
Needs to be fit (see
BaseFittedTransformTorch
). Returns the proportion of scores in the reference dataset that are greater than the score of interest. Output is between1
and0
. Small values are likely to be outliers.
- class alibi_detect.od.pytorch.ensemble.ShiftAndScaleNormalizer(*args: Any, **kwargs: Any)[source]
Bases:
BaseTransformTorch
,FitMixinTorch
- __init__()[source]
Maps scores to their normalized values.
Needs to be fit (see
BaseFittedTransformTorch
). Subtracts the dataset mean and scales by the standard deviation.
- class alibi_detect.od.pytorch.ensemble.TopKAggregator(k=None)[source]
Bases:
BaseTransformTorch