xaib.base

class xaib.base.Dataset(*args: Any, **kwargs: Any)[source]

Dataset is a wrapper around any collection of items to put in the ML model for inference




class xaib.base.Model(*args: Any, **kwargs: Any)[source]

Model is a wrapper around any inference of ML or other solution in the form y = f(x) it implements method predict that given certain data x returns the response y

predict(x: Any) Any[source]

Method to encapsulate inference. May include preprocessing steps to make model self-sufficient.




class xaib.base.Explainer(*args: Any, **kwargs: Any)[source]

Explainer is a special kind of Model e = g(f, x) that accepts another Model and data as input and also returns a response e - an explanation

predict(x: Any, model: Model) Any[source]

Method to encapsulate inference. May include preprocessing steps to make model self-sufficient.




class xaib.base.Case(*args: Any, **kwargs: Any)[source]

Case is a collection of Metrics which represent some high-level property of an Explainer

add_metric(name: str, metric: Metric) None[source]
evaluate(name: str, expl: Explainer, metrics_kwargs: Dict[str, Dict[Any, Any]] | None = None, **kwargs: Any) None[source]

Evaluates model against any metrics. Should not return any value, just populate self.metrics dict.




class xaib.base.Metric(ds: Dataset, model: Model, *args: Any, **kwargs: Any)[source]

Metric is an entity which accepts Explainer, Model and Dataset and outputs a metric corresponding to the quality of Explainer v = m(g, f, x)

compute(expl: Explainer, batch_size: int = 1, expl_kwargs: Dict[Any, Any] | None = None) Any[source]
evaluate(name: str, expl: Explainer, batch_size: int = 1, expl_kwargs: Dict[Any, Any] | None = None, **kwargs: Any) None[source]

Evaluates model against any metrics. Should not return any value, just populate self.metrics dict.




class xaib.base.Factory[source]

Collection of constructors to build and return objects from predefined hardcoded or added dynamically constructors

add(name: str, constructor: Type, constr_kwargs: Any | None = None) None[source]
get(name: str) Dict[str, Any] | Any[source]
get_constructor(name: str) Type[source]
get_names()[source]