alibi_detect.saving.loading module

alibi_detect.saving.loading.load_detector(filepath, enable_unsafe_loading=False, **kwargs)[source]

Load outlier, drift or adversarial detector.

Parameters:
  • filepath (Union[str, PathLike]) – Load directory.

  • enable_unsafe_loading (bool) – Sets allow_pickle=True when a np.ndarray is loaded from a .npy file referenced in the detector config. Needed if you have to load objects. Only applied if the filepath is config.toml or a directory containing a config.toml. It has security implications: https://nvd.nist.gov/vuln/detail/cve-2019-6446.

Return type:

Union[Detector, ConfigurableDetector]

Returns:

Loaded outlier or adversarial detector object.

alibi_detect.saving.loading.read_config(filepath)[source]

This function reads a detector toml config file and returns a dict specifying the detector.

Parameters:

filepath (Union[PathLike, str]) – The filepath to the config.toml file.

Return type:

dict

Returns:

Parsed toml dictionary.

alibi_detect.saving.loading.resolve_config(cfg, config_dir, enable_unsafe_loading=False)[source]

Resolves artefacts in a config dict. For example x_ref=’x_ref.npy’ is resolved by loading the np.ndarray from the .npy file. For a list of fields that are resolved, see https://docs.seldon.io/projects/alibi-detect/en/stable/overview/config_file.html.

Parameters:
  • cfg (dict) – The unresolved config dict.

  • config_dir (Optional[Path]) – Filepath to directory the config.toml is located in. Only required if different from the runtime directory, and artefacts are specified with filepaths relative to the config.toml file.

  • enable_unsafe_loading (bool) – If set to true, allow_pickle=True is set in np.load(). Needed if you have to load objects. It has security implications: https://nvd.nist.gov/vuln/detail/cve-2019-6446

Return type:

dict

Returns:

The resolved config dict.