alibi_detect.od.pytorch.base
TorchOutlierDetector
TorchOutlierDetectorInherits from: Module, FitMixinTorch, ABC
Base class for torch backend outlier detection algorithms.
Constructor
TorchOutlierDetector(self, device: Union[typing_extensions.Literal['cuda', 'gpu', 'cpu'], ForwardRef('torch.device'), NoneType] = None)device
Union[Literal[cuda, gpu, cpu], torch.device, None]
None
Methods
check_threshold_inferred
check_threshold_inferredcheck_threshold_inferred()Check if threshold is inferred.
infer_threshold
infer_thresholdinfer_threshold(x: torch.Tensor, fpr: float)Infer the threshold for the data. Prerequisite for outlier predictions.
x
torch.Tensor
Data to infer the threshold for.
fpr
float
False positive rate to use for threshold inference.
predict
predictpredict(x: torch.Tensor) -> alibi_detect.od.pytorch.base.TorchOutlierDetectorOutputPredict outlier labels for the data.
Computes the outlier scores. If the detector is not fit on reference data we raise an error. If the threshold is inferred, the outlier labels and p-values are also computed and returned. Otherwise, the outlier labels and p-values are set to None.
x
torch.Tensor
Data to predict.
Returns
Type:
alibi_detect.od.pytorch.base.TorchOutlierDetectorOutput
score
scorescore(x: torch.Tensor) -> torch.TensorScore the data.
x
torch.Tensor
Data to score.
Returns
Type:
torch.Tensor
TorchOutlierDetectorOutput
TorchOutlierDetectorOutputOutput of the outlier detector.
Fields
threshold_inferred
bool
``
instance_score
torch.Tensor
``
threshold
Optional[torch.Tensor]
``
is_outlier
Optional[torch.Tensor]
``
p_value
Optional[torch.Tensor]
``
Constructor
TorchOutlierDetectorOutput(self, threshold_inferred: bool, instance_score: torch.Tensor, threshold: Optional[torch.Tensor], is_outlier: Optional[torch.Tensor], p_value: Optional[torch.Tensor]) -> Nonethreshold_inferred
bool
instance_score
torch.Tensor
threshold
Optional[torch.Tensor]
is_outlier
Optional[torch.Tensor]
p_value
Optional[torch.Tensor]
Methods
to_frontend_dtype
to_frontend_dtypeto_frontend_dtype()Functions
to_frontend_dtype
to_frontend_dtypeto_frontend_dtype(x: Union[torch.Tensor, alibi_detect.od.pytorch.base.TorchOutlierDetectorOutput]) -> Union[numpy.ndarray, Dict[str, numpy.ndarray]]Converts any torch tensors found in input to numpy arrays.
Takes a torch tensor or TorchOutlierDetectorOutput and converts any torch tensors found to numpy arrays
x
Union[torch.Tensor, alibi_detect.od.pytorch.base.TorchOutlierDetectorOutput]
Data to convert.
Returns
Type:
Union[numpy.ndarray, Dict[str, numpy.ndarray]]
Last updated
Was this helpful?

