omnixai.explainers.nlp package
omnixai.explainers.nlp.auto module
- class omnixai.explainers.nlp.auto.NLPExplainer(explainers, mode, model, data=[], preprocess=None, postprocess=None, params=None)
Bases:
AutoExplainerBaseThe class derived from AutoExplainerBase for NLP tasks, allowing users to choose multiple explainers and generate different explanations at the same time.
explainer = NLPExplainer( explainers=["ig", "lime"], mode="classification", model=model, preprocess=preprocess_function, postprocess=postprocess_function ) local_explanations = explainer.explain(x)
- Parameters
explainers (
Collection) – The names or alias of the explainers to use.mode (
str) – The task type, e.g. classification, regression or qa.model (
Any) – The machine learning model to explain, which can be a scikit-learn model, a tensorflow model, a torch model, or a black-box prediction function.data (
Text) – The training data used to initialize explainers. It can be empty, e.g., data = Text(), for those explainers such as LIME and SHAP that don’t require training data.preprocess (
Optional[Callable]) – The preprocessing function that converts the raw inputs into the inputs ofmodel.postprocess (
Optional[Callable]) – The postprocessing function that transforms the outputs ofmodelto a user-specific form, e.g., the predicted probability for each class.params (
Optional[Dict]) – A dict containing the additional parameters for initializing each explainer, e.g., params[“lime”] = {“param_1”: param_1, …}.
- static list_explainers()
List the supported explainers.