class_docstr: Unit test Smart Predictor class
class_docstr_tok: ["Unit","test","Smart","Predictor","class"]
docstr: Unit test 1 summarize method
docstr_tok: ["Unit","test","1","summarize","method"]
code: def test_summarize_1(self):
      """
      Unit test 1 summarize method
      """
      clf = cb.CatBoostRegressor(n_estimators=1).fit(
          self.df_3[["x1", "x2"]], self.df_3["y"]
      )
      backend = ShapBackend(model=clf)
  
      predictor_1 = self.predictor_3
      predictor_1.model = clf
      predictor_1.backend = backend
      predictor_1.data = {
          "x": None,
          "x_preprocessed": None,
          "x_postprocessed": None,
          "ypred": None,
          "contributions": None,
      }
  
      predictor_1.data["x"] = self.df_3[["x1", "x2"]]
      predictor_1.data["x_postprocessed"] = self.df_3[["x1", "x2"]]
      predictor_1.data["x_preprocessed"] = self.df_3[["x1", "x2"]]
      predictor_1.data["ypred"] = self.df_3["y"]
      contribution = pd.DataFrame(
          [
              [0.0, 0.094286],
              [0.0, -0.023571],
              [0.0, -0.023571],
              [0.0, -0.023571],
              [0.0, -0.023571],
          ],
          columns=["x1", "x2"],
      )
      predictor_1.data["contributions"] = contribution
  
      output = predictor_1.summarize()
      print(output)
      expected_output = pd.DataFrame(
          {
              "y": [1, 1, 0, 0, 0],
              "feature_1": [
                  "weight",
                  "weight",
                  "weight",
                  "weight",
                  "weight",
              ],
              "value_1": ["90", "78", "84", "85", "53"],
              "contribution_1": [
                  "0.0942857",
                  "-0.0235714",
                  "-0.0235714",
                  "-0.0235714",
                  "-0.0235714",
              ],
              "feature_2": ["age", "age", "age", "age", "age"],
              "value_2": ["25", "39", "50", "43", "67"],
              "contribution_2": ["0", "0", "0", "0", "0"],
          },
          dtype=object,
      )
      expected_output["y"] = expected_output["y"].astype(int)
  
      feature_expected = [
          column
          for column in expected_output.columns
          if column.startswith("feature_")
      ]
      feature_output = [
          column
          for column in output.columns
          if column.startswith("feature_")
      ]
  
      value_expected = [
          column
          for column in expected_output.columns
          if column.startswith("value_")
      ]
      value_output = [
          column
          for column in output.columns
          if column.startswith("value_")
      ]
  
      contribution_expected = [
          column
          for column in expected_output.columns
          if column.startswith("contribution_")
      ]
      contribution_output = [
          column
          for column in output.columns
          if column.startswith("contribution_")
      ]
  
      assert expected_output.shape == output.shape
      assert len(feature_expected) == len(feature_output)
      assert len(value_expected) == len(value_output)
      assert len(contribution_expected) == len(contribution_output)
  
imports: import unittest
  from shapash.explainer.smart_predictor import SmartPredictor
  from shapash import SmartExplainer
  from shapash.explainer.smart_state import SmartState
  from shapash.explainer.multi_decorator import MultiDecorator
  from shapash.backend import ShapBackend
  import os
  from os import path
  from pathlib import Path
  import pandas
  import numpy
  import catboost
  from catboost import Pool
  import category_encoders
  from unittest.mock import patch
  import types
  from sklearn.compose import ColumnTransformer
  import sklearn.preprocessing
  import shap
label_desc: Use image node_id 26 for calling the TestSmartPredictor obj's underlying member method code with example usage: obj.test_summarize_1() without return types