alibi_detect.od.sr
Constants
logger
loggerlogger: logging.Logger = <Logger alibi_detect.od.sr (WARNING)>Instances of the Logger class represent a single logging channel. A "logging channel" indicates an area of an application. Exactly how an "area" is defined is up to the application developer. Since an application can have any number of areas, logging channels are identified by a unique string. Application areas can be nested (e.g. an area of "input processing" might include sub-areas "read CSV files", "read XLS files" and "read Gnumeric files"). To cater for this natural nesting, channel names are organized into a namespace hierarchy where levels are separated by periods, much like the Java or Python package namespace. So in the instance given above, channel names might be "input" for the upper level, and "input.csv", "input.xls" and "input.gnu" for the sub-levels. There is no arbitrary limit to the depth of nesting.
EPSILON
EPSILONEPSILON: float = 1e-08Convert a string or number to a floating point number, if possible.
Padding
PaddingInherits from: str, Enum
An enumeration.
Side
SideInherits from: str, Enum
An enumeration.
SpectralResidual
SpectralResidualInherits from: BaseDetector, ThresholdMixin, ABC
Constructor
SpectralResidual(self, threshold: float = None, window_amp: int = None, window_local: int = None, padding_amp_method: typing_extensions.Literal['constant', 'replicate', 'reflect'] = 'reflect', padding_local_method: typing_extensions.Literal['constant', 'replicate', 'reflect'] = 'reflect', padding_amp_side: typing_extensions.Literal['bilateral', 'left', 'right'] = 'bilateral', n_est_points: int = None, n_grad_points: int = 5) -> Nonethreshold
Optional[float]
None
Threshold used to classify outliers. Relative saliency map distance from the moving average.
window_amp
Optional[int]
None
Window for the average log amplitude.
window_local
Optional[int]
None
Window for the local average of the saliency map. Note that the averaging is performed over the previous window_local data points (i.e., is a local average of the preceding window_local points for the current index).
padding_amp_method
Literal[constant, replicate, reflect]
'reflect'
Padding method to be used prior to each convolution over log amplitude. Possible values: constant
padding_local_method
Literal[constant, replicate, reflect]
'reflect'
Padding method to be used prior to each convolution over saliency map. Possible values: constant
padding_amp_side
Literal[bilateral, left, right]
'bilateral'
Whether to pad the amplitudes on both sides or only on one side. Possible values: bilateral
n_est_points
Optional[int]
None
Number of estimated points padded to the end of the sequence.
n_grad_points
int
5
Number of points used for the gradient estimation of the additional points padded to the end of the sequence.
Methods
add_est_points
add_est_pointsadd_est_points(X: numpy.ndarray, t: numpy.ndarray) -> numpy.ndarrayPad the time series with additional points since the method works better if the anomaly point
is towards the center of the sliding window.
X
numpy.ndarray
Uniformly sampled time series instances.
t
numpy.ndarray
Equidistant timestamps corresponding to each input instances (i.e, the array should contain numerical values in increasing order).
Returns
Type:
numpy.ndarray
compute_grads
compute_gradscompute_grads(X: numpy.ndarray, t: numpy.ndarray) -> numpy.ndarraySlope of the straight line between different points of the time series
multiplied by the average time step size.
X
numpy.ndarray
Uniformly sampled time series instances.
t
numpy.ndarray
Equidistant timestamps corresponding to each input instances (i.e, the array should contain numerical values in increasing order).
Returns
Type:
numpy.ndarray
infer_threshold
infer_thresholdinfer_threshold(X: numpy.ndarray, t: Optional[numpy.ndarray] = None, threshold_perc: float = 95.0) -> NoneUpdate threshold by a value inferred from the percentage of instances considered to be
outliers in a sample of the dataset.
X
numpy.ndarray
Uniformly sampled time series instances.
t
Optional[numpy.ndarray]
None
Equidistant timestamps corresponding to each input instances (i.e, the array should contain numerical values in increasing order). If not provided, the timestamps will be replaced by an array of integers [0, 1, ... , N - 1], where N is the size of the input time series.
threshold_perc
float
95.0
Percentage of X considered to be normal based on the outlier score.
Returns
Type:
None
pad_same
pad_samepad_same(X: numpy.ndarray, W: numpy.ndarray, method: str = 'replicate', side: str = 'bilateral') -> numpy.ndarrayAdds padding to the time series X such that after applying a valid convolution with a kernel/filter
w, the resulting time series has the same shape as the input X.
X
numpy.ndarray
Time series to be padded
W
numpy.ndarray
Convolution kernel/filter.
method
str
'replicate'
Padding method to be used. Possible values:
side
str
'bilateral'
Whether to pad the time series bilateral or only on one side. Possible values:
Returns
Type:
numpy.ndarray
predict
predictpredict(X: numpy.ndarray, t: Optional[numpy.ndarray] = None, return_instance_score: bool = True) -> Dict[Dict[str, str], Dict[numpy.ndarray, numpy.ndarray]]Compute outlier scores and transform into outlier predictions.
X
numpy.ndarray
Uniformly sampled time series instances.
t
Optional[numpy.ndarray]
None
Equidistant timestamps corresponding to each input instances (i.e, the array should contain numerical values in increasing order). If not provided, the timestamps will be replaced by an array of integers [0, 1, ... , N - 1], where N is the size of the input time series.
return_instance_score
bool
True
Whether to return instance level outlier scores.
Returns
Type:
Dict[Dict[str, str], Dict[numpy.ndarray, numpy.ndarray]]
saliency_map
saliency_mapsaliency_map(X: numpy.ndarray) -> numpy.ndarrayCompute saliency map.
X
numpy.ndarray
Uniformly sampled time series instances.
Returns
Type:
numpy.ndarray
score
scorescore(X: numpy.ndarray, t: Optional[numpy.ndarray] = None) -> numpy.ndarrayCompute outlier scores.
X
numpy.ndarray
Uniformly sampled time series instances.
t
Optional[numpy.ndarray]
None
Equidistant timestamps corresponding to each input instances (i.e, the array should contain numerical values in increasing order). If not provided, the timestamps will be replaced by an array of integers [0, 1, ... , N - 1], where N is the size of the input time series.
Returns
Type:
numpy.ndarray
Last updated
Was this helpful?

