alibi.api.interfaces module

class alibi.api.interfaces.Explainer(meta={'explanations': [], 'name': None, 'params': {}, 'type': []})[source]

Bases: abc.ABC

Base class for explainer algorithms

abstract explain(X)[source]
Return type

Explanation

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

class alibi.api.interfaces.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)