alibi_detect.saving package

alibi_detect.saving.load_detector(filepath, **kwargs)[source]

Load outlier, drift or adversarial detector.

Parameters:

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

Return type:

Union[Detector, ConfigurableDetector]

Returns:

Loaded outlier or adversarial detector object.

alibi_detect.saving.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.resolve_config(cfg, config_dir)[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.

Return type:

dict

Returns:

The resolved config dict.

alibi_detect.saving.save_detector(detector, filepath, legacy=False)[source]

Save outlier, drift or adversarial detector.

Parameters:
  • detector (Union[Detector, ConfigurableDetector]) – Detector object.

  • filepath (Union[str, PathLike]) – Save directory.

  • legacy (bool) – Whether to save in the legacy .dill format instead of via a config.toml file. Default is False. This option will be removed in a future version.

Return type:

None

alibi_detect.saving.validate_config(cfg, resolved=False)[source]

Validates a detector config dict by passing the dict to the detector’s pydantic model schema.

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

  • resolved (bool) – Whether the config is resolved or not. For example, if resolved=True, x_ref is expected to be a np.ndarray, wheras if resolved=False, x_ref is expected to be a str.

Return type:

dict

Returns:

The validated config dict, with missing fields set to their default values.

alibi_detect.saving.write_config(cfg, filepath)[source]

Save an unresolved detector config dict to a TOML file.

Parameters:
  • cfg (dict) – Unresolved detector config dict.

  • filepath (Union[str, PathLike]) – Filepath to directory to save ‘config.toml’ file in.

Submodules