def explain_tabular(self, trainset, labels, instance, num_features=5, kernel_width=3):
        """Explain categorical and numeric features for a prediction.

        It analyze the prediction by LIME, and returns a report of the most impactful tabular
        features contributing to certain labels.

        Args:
          trainset: a DataFrame representing the training features that LIME can use to decide
              value distributions.
          labels: a list of labels to explain.
          instance: the prediction instance. It needs to conform to model's input. Can be a csv
              line string, or a dict.
          num_features: maximum number of features to show.
          kernel_width: Passed to LIME LimeTabularExplainer directly.

        Returns:
          A LIME's lime.explanation.Explanation.
        """
        from lime.lime_tabular import LimeTabularExplainer

        if isinstance(instance, six.string_types):
            instance = next(csv.DictReader([instance], fieldnames=self._headers))

        categories = self._get_unique_categories(trainset)
        np_trainset = self._preprocess_data_for_tabular_explain(trainset, categories)
        predict_fn = self._make_tabular_predict_fn(labels, instance, categories)
        prediction_df = pd.DataFrame([instance])
        prediction_instance = self._preprocess_data_for_tabular_explain(prediction_df, categories)

        explainer = LimeTabularExplainer(
            np_trainset,
            feature_names=(self._categorical_columns + self._numeric_columns),
            class_names=labels,
            categorical_features=range(len(categories)),
            categorical_names={i: v for i, v in enumerate(categories)},
            kernel_width=kernel_width)

        exp = explainer.explain_instance(
            prediction_instance[0],
            predict_fn,
            num_features=num_features,
            labels=range(len(labels)))
        return exp
Explain categorical and numeric features for a prediction.

        It analyze the prediction by LIME, and returns a report of the most impactful tabular
        features contributing to certain labels.

        Args:
          trainset: a DataFrame representing the training features that LIME can use to decide
              value distributions.
          labels: a list of labels to explain.
          instance: the prediction instance. It needs to conform to model's input. Can be a csv
              line string, or a dict.
          num_features: maximum number of features to show.
          kernel_width: Passed to LIME LimeTabularExplainer directly.

        Returns:
          A LIME's lime.explanation.Explanation.