alibi.api.interfaces module

class alibi.api.interfaces.AlibiPrettyPrinter(*args, **kwargs)[source]

Bases: pprint.PrettyPrinter

Overrides the built in dictionary pretty representation to look more similar to the external prettyprinter libary.

class alibi.api.interfaces.Explainer(meta=NOTHING)[source]

Bases: abc.ABC

Base class for explainer algorithms

abstract explain(X)[source]
Return type

Explanation

classmethod load(path, predictor)[source]

Load an explainer from disk.

Parameters
  • path (Union[str, PathLike]) – Path to a directory containing the saved explainer.

  • predictor (Any) – Model or prediction function used to originally initialize the explainer.

Return type

Explainer

Returns

An explainer instance.

reset_predictor(predictor)[source]
Return type

None

save(path)[source]

Save an explainer to disk. Uses the dill module.

Parameters

path (Union[str, PathLike]) – Path to a directory. A new directory will be created if one does not exist.

Return type

None

class alibi.api.interfaces.Explanation(meta, data)[source]

Bases: object

Explanation class returned by explainers.

__attrs_post_init__()[source]

Expose keys stored in self.meta and self.data as attributes of the class.

__getitem__(item)[source]

This method is purely for deprecating previous behaviour of accessing explanation data via items in the returned dictionary.

classmethod from_json(jsonrepr)[source]

Create an instance of an Explanation class using a json representation of the Explanation.

Parameters

jsonrepr – json representation of an explanation

Return type

Explanation

Returns

An Explanation object

to_json()[source]

Serialize the explanation data and metadata into a json format.

Return type

str

Returns

String containing json representation of the explanation

class alibi.api.interfaces.FitMixin[source]

Bases: abc.ABC

abstract fit(X)[source]
Return type

Explainer

alibi.api.interfaces.default_meta()[source]
Return type

dict