alibi_detect.utils.visualize module

alibi_detect.utils.visualize.plot_feature_outlier_image(od_preds, X, X_recon=None, instance_ids=None, max_instances=5, outliers_only=False, n_channels=3, figsize=(20, 20))[source]

Plot feature (pixel) wise outlier scores for images.

Parameters
  • od_preds (Dict) – Output of an outlier detector’s prediction.

  • X (numpy.ndarray) – Batch of instances to apply outlier detection to.

  • X_recon (Optional[numpy.ndarray]) – Reconstructed instances of X.

  • instance_ids (Optional[list]) – List with indices of instances to display.

  • max_instances (int) – Maximum number of instances to display.

  • outliers_only (bool) – Whether to only show outliers or not.

  • n_channels (int) – Number of channels of the images.

  • figsize (tuple) – Tuple for the figure size.

Return type

None

alibi_detect.utils.visualize.plot_feature_outlier_tabular(od_preds, X, X_recon=None, threshold=None, instance_ids=None, max_instances=5, top_n=1000000000000, outliers_only=False, feature_names=None, width=0.2, figsize=(20, 10))[source]

Plot feature wise outlier scores for tabular data.

Parameters
  • od_preds (Dict) – Output of an outlier detector’s prediction.

  • X (numpy.ndarray) – Batch of instances to apply outlier detection to.

  • X_recon (Optional[numpy.ndarray]) – Reconstructed instances of X.

  • threshold (Optional[float]) – Threshold used for outlier score to determine outliers.

  • instance_ids (Optional[list]) – List with indices of instances to display.

  • max_instances (int) – Maximum number of instances to display.

  • top_n (int) – Maixmum number of features to display, ordered by outlier score.

  • outliers_only (bool) – Whether to only show outliers or not.

  • feature_names (Optional[list]) – List with feature names.

  • width (float) – Column width for bar charts.

  • figsize (tuple) – Tuple for the figure size.

Return type

None

alibi_detect.utils.visualize.plot_feature_outlier_ts(od_preds, X, threshold, window=None, t=None, X_orig=None, width=0.2, figsize=(20, 8), ylim=(None, None))[source]

Plot feature wise outlier scores for time series data.

Parameters
  • od_preds (Dict) – Output of an outlier detector’s prediction.

  • X (numpy.ndarray) – Time series to apply outlier detection to.

  • threshold (float) – Threshold used to classify outliers or adversarial instances.

  • window (Optional[tuple]) – Start and end timestep to plot.

  • t (Optional[numpy.ndarray]) – Timesteps.

  • X_orig (Optional[numpy.ndarray]) – Optional original time series without outliers.

  • width (float) – Column width for bar charts.

  • figsize (tuple) – Tuple for the figure size.

  • ylim (tuple) – Min and max y-axis values for the outlier scores.

Return type

None

alibi_detect.utils.visualize.plot_instance_score(preds, target, labels, threshold, ylim=(None, None))[source]

Scatter plot of a batch of outlier or adversarial scores compared to the threshold.

Parameters
  • preds (Dict) – Dictionary returned by predictions of an outlier or adversarial detector.

  • target (numpy.ndarray) – Ground truth.

  • labels (numpy.ndarray) – List with names of classification labels.

  • threshold (float) – Threshold used to classify outliers or adversarial instances.

  • ylim (tuple) – Min and max y-axis values.

Return type

None