# alibi_detect.utils.perturbation module¶

alibi_detect.utils.perturbation.apply_mask(X, mask_size=(4, 4), n_masks=1, coord=None, channels=[0, 1, 2], mask_type='uniform', noise_distr=(0, 1), noise_rng=(0, 1), clip_rng=(0, 1))[source]

Mask images. Can zero out image patches or add normal or uniformly distributed noise.

Parameters
Return type

Tuple[numpy.ndarray, numpy.ndarray]

Returns

alibi_detect.utils.perturbation.inject_outlier_ts(X, perc_outlier, perc_window=10, n_std=2.0, min_std=1.0)[source]

Inject outliers in both univariate and multivariate time series data.

Parameters
• X (numpy.ndarray) – Time series data to perturb (inject outliers).

• perc_outlier (int) – Percentage of observations which are perturbed to outliers. For multivariate data, the percentage is evenly split across the individual time series.

• perc_window (int) – Percentage of the observations used to compute the standard deviation used in the perturbation.

• n_std (float) – Number of standard deviations in the window used to perturb the original data.

• min_std (float) – Minimum number of standard deviations away from the current observation. This is included because of the stochastic nature of the perturbation which could lead to minimal perturbations without a floor.

Return type

Bunch

Returns

Bunch object with the perturbed time series and the outlier labels.