interpret_community.common.blackbox_explainer module¶
Defines the black box explainer API, which can either take in a black box model or function.
- class interpret_community.common.blackbox_explainer.BlackBoxExplainer(model, is_function=False, model_task=ModelTask.Unknown, **kwargs)¶
Bases:
interpret_community.common.base_explainer.BaseExplainer
,interpret_community.common.blackbox_explainer.BlackBoxMixin
The base class for black box models or functions.
- Parameters
model (object) – The model to explain or function if is_function is True. A model that implements sklearn.predict or sklearn.predict_proba or function that accepts a 2d ndarray.
is_function (bool) – Default is false. Set to True if passing sklearn.predict or sklearn.predict_proba function instead of model.
- class interpret_community.common.blackbox_explainer.BlackBoxMixin(model, is_function=False, model_task=ModelTask.Unknown, **kwargs)¶
Bases:
interpret_community.common.chained_identity.ChainedIdentity
Mixin for black box models or functions.
- Parameters
model (object) – The model to explain or function if is_function is True. A model that implements sklearn.predict or sklearn.predict_proba or function that accepts a 2d ndarray.
is_function (bool) – Default is False. Set to True if passing sklearn.predict or sklearn.predict_proba function instead of model.
- interpret_community.common.blackbox_explainer.add_prepare_function_and_summary_method(cls)¶
Decorate blackbox explainer to allow aggregating local explanations to global.
Adds two protected methods _function_subset_wrapper and _prepare_function_and_summary to the blackbox explainer. The former creates a wrapper around the prediction function for explaining subsets of features in the evaluation samples dataset. The latter calls the former to create a wrapper and also computes the summary background dataset for the explainer.
- interpret_community.common.blackbox_explainer.init_blackbox_decorator(init_func)¶
Decorate a constructor to wrap initialization examples in a DatasetWrapper.
Provided for convenience for tabular data explainers.
- Parameters
init_func (Initialization constructor.) – Initialization constructor where the second argument is a dataset.