def _compute_explanations(self, local: bool, data: Any):
        """Compute explanations using MimicWrapper.

        :param local: True if local explanations are requested
                and False otherwise.
        :type local: bool
        :param data: The data point(s) for which the explanations
                     need to be generated.
        :type data: Any
        :return: The computed explanations.
        :rtype: Any
        """
        if self._classes is not None:
            model_task = ModelTask.Classification
        else:
            model_task = ModelTask.Regression

        explainer = MimicExplainer(
            self._model,
            self._initialization_examples,
            self._surrogate_model,
            features=self._features,
            model_task=model_task,
            classes=self._classes,
            categorical_features=self._categorical_features)
        return explainer.explain_global(data, include_local=local)
 def test_json_serialize_mimic_no_features(self, iris, iris_svm_model):
     explainer = MimicExplainer(
         iris_svm_model,
         iris[DatasetConstants.X_TRAIN],
         LGBMExplainableModel,
         max_num_of_augmentations=10,
         classes=iris[DatasetConstants.CLASSES].tolist())
     explanation = explainer.explain_global()
     verify_serialization(explanation)
 def compute(self):
     """Creates an explanation by running the explainer on the model."""
     if self._is_run:
         return
     model_task = ModelTask.Unknown
     explainer = MimicExplainer(self._model,
                                self._initialization_examples,
                                self._surrogate_model,
                                features=self._features,
                                model_task=model_task,
                                classes=self._classes)
     self._explanation = explainer.explain_global(self._evaluation_examples)
示例#4
0
 def create_explainer(model, x_train, **kwargs):
     return MimicExplainer(
         model,
         x_train,
         explainable_model,
         explainable_model_args=explainable_model_args.copy(),
         **kwargs)
示例#5
0
 def create_explainer(model, x_train, **kwargs):
     return MimicExplainer(
         model,
         x_train,
         explainable_model,
         max_num_of_augmentations=10,
         explainable_model_args=explainable_model_args.copy(),
         **kwargs)
    def compute(self):
        """Creates an explanation by running the explainer on the model."""
        if not self._is_added:
            return
        if self._is_run:
            return
        if self._classes is not None:
            model_task = ModelTask.Classification
        else:
            model_task = ModelTask.Regression

        explainer = MimicExplainer(
            self._model,
            self._initialization_examples,
            self._surrogate_model,
            features=self._features,
            model_task=model_task,
            classes=self._classes,
            categorical_features=self._categorical_features)
        self._explanation = explainer.explain_global(self._evaluation_examples)