alibi_detect.od.pytorch.ensemble
AverageAggregator
AverageAggregatorInherits from: BaseTransformTorch, Module
Constructor
AverageAggregator(self, weights: Optional[torch.Tensor] = None)weights
Optional[torch.Tensor]
None
Optional parameter to weight the scores. If weights is left None then will be set to a vector of ones.
Methods
transform
transformtransform(scores: torch.Tensor) -> torch.TensorAverages the scores of the detectors in an ensemble. If weights were passed in the __init__
then these are used to weight the scores.
scores
torch.Tensor
Torch.Tensor of scores from ensemble of detectors.
Returns
Type:
torch.Tensor
BaseTransformTorch
BaseTransformTorchInherits from: Module
Constructor
BaseTransformTorch(self)Methods
forward
forwardforward(x: torch.Tensor) -> torch.Tensorx
torch.Tensor
Returns
Type:
torch.Tensor
transform
transformtransform(x: torch.Tensor)Public transform method.
x
torch.Tensor
torch.Tensor array to be transformed
Ensembler
EnsemblerInherits from: BaseTransformTorch, Module, FitMixinTorch, ABC
Constructor
Ensembler(self, normalizer: Optional[alibi_detect.od.pytorch.ensemble.BaseTransformTorch] = None, aggregator: alibi_detect.od.pytorch.ensemble.BaseTransformTorch = None)normalizer
Optional[alibi_detect.od.pytorch.ensemble.BaseTransformTorch]
None
BaseFittedTransformTorch object to normalize the scores. If None then no normalization is applied.
aggregator
Optional[alibi_detect.od.pytorch.ensemble.BaseTransformTorch]
None
BaseTransformTorch object to aggregate the scores. If None defaults to AverageAggregator.
Methods
fit
fitfit(x: torch.Tensor) -> typing_extensions.SelfFit the normalizer to the scores.
x
torch.Tensor
Torch.Tensor of scores from ensemble of detectors.
Returns
Type:
typing_extensions.Self
transform
transformtransform(x: torch.Tensor) -> torch.TensorApply the normalizer and aggregator to the scores.
x
torch.Tensor
Torch.Tensor of scores from ensemble of detectors.
Returns
Type:
torch.Tensor
FitMixinTorch
FitMixinTorchInherits from: ABC
Methods
check_fitted
check_fittedcheck_fitted()Checks to make sure object has been fitted.
fit
fitfit(x_ref: torch.Tensor) -> typing_extensions.SelfAbstract fit method.
x_ref
torch.Tensor
x
torch.Tensor to fit object on.
Returns
Type:
typing_extensions.Self
MaxAggregator
MaxAggregatorInherits from: BaseTransformTorch, Module
Constructor
MaxAggregator(self)Methods
transform
transformtransform(scores: torch.Tensor) -> torch.TensorTakes the maximum score of a set of detectors in an ensemble.
scores
torch.Tensor
Torch.Tensor of scores from ensemble of detectors.
Returns
Type:
torch.Tensor
MinAggregator
MinAggregatorInherits from: BaseTransformTorch, Module
Constructor
MinAggregator(self)Methods
transform
transformtransform(scores: torch.Tensor) -> torch.TensorTakes the minimum score of a set of detectors in an ensemble.
scores
torch.Tensor
Torch.Tensor of scores from ensemble of detectors.
Returns
Type:
torch.Tensor
PValNormalizer
PValNormalizerInherits from: BaseTransformTorch, Module, FitMixinTorch, ABC
Constructor
PValNormalizer(self)Methods
fit
fitfit(val_scores: torch.Tensor) -> typing_extensions.SelfFit transform on scores.
val_scores
torch.Tensor
score outputs of ensemble of detectors applied to reference data.
Returns
Type:
typing_extensions.Self
transform
transformtransform(scores: torch.Tensor) -> torch.TensorTransform scores to 1 - p-values.
scores
torch.Tensor
Torch.Tensor of scores from ensemble of detectors.
Returns
Type:
torch.Tensor
ShiftAndScaleNormalizer
ShiftAndScaleNormalizerInherits from: BaseTransformTorch, Module, FitMixinTorch, ABC
Constructor
ShiftAndScaleNormalizer(self)Methods
fit
fitfit(val_scores: torch.Tensor) -> typing_extensions.SelfComputes the mean and standard deviation of the scores and stores them.
val_scores
torch.Tensor
Torch.Tensor of scores from ensemble of detectors.
Returns
Type:
typing_extensions.Self
transform
transformtransform(scores: torch.Tensor) -> torch.TensorTransform scores to normalized values. Subtracts the mean and scales by the standard deviation.
scores
torch.Tensor
Torch.Tensor of scores from ensemble of detectors.
Returns
Type:
torch.Tensor
TopKAggregator
TopKAggregatorInherits from: BaseTransformTorch, Module
Constructor
TopKAggregator(self, k: Optional[int] = None)k
Optional[int]
None
number of scores to take the mean of. If k is left None then will be set to half the number of scores passed in the forward call.
Methods
transform
transformtransform(scores: torch.Tensor) -> torch.TensorTakes the mean of the top k scores.
scores
torch.Tensor
Torch.Tensor of scores from ensemble of detectors.
Returns
Type:
torch.Tensor
Last updated
Was this helpful?

