class_docstr: Unit test Smart Predictor class
class_docstr_tok: ["Unit","test","Smart","Predictor","class"]
docstr: Unit test check_shape_contributions 1
docstr_tok: ["Unit","test","check_shape_contributions","1"]
code: def test_check_contributions(self):
      """
      Unit test check_shape_contributions 1
      """
  
      shap_values = self.clf_2.get_feature_importance(
          Pool(self.df_encoded_2), type="ShapValues"
      )
  
      predictor_1 = self.predictor_2
  
      predictor_1.data = {
          "x": None,
          "ypred": None,
          "contributions": None,
          "x_preprocessed": None,
      }
      predictor_1.data["x"] = self.df_2[["x1", "x2"]]
      predictor_1.data["x_preprocessed"] = self.df_2[["x1", "x2"]]
      predictor_1.data["ypred"] = self.df_2["y"]
  
      adapt_contrib = [
          np.array(
              [
                  [-0.04395604, 0.13186813],
                  [-0.04395604, 0.13186813],
                  [-0.0021978, 0.01318681],
                  [-0.0021978, 0.01318681],
                  [-0.04395604, 0.13186813],
              ]
          ),
          np.array(
              [
                  [0.04395604, -0.13186813],
                  [0.04395604, -0.13186813],
                  [0.0021978, -0.01318681],
                  [0.0021978, -0.01318681],
                  [0.04395604, -0.13186813],
              ]
          ),
      ]
      contributions = list()
      for element in adapt_contrib:
          contributions.append(
              pd.DataFrame(element, columns=["x1", "x2"])
          )
  
      predictor_1.backend.state = MultiDecorator(SmartState())
      predictor_1.check_contributions(contributions)
  
      with self.assertRaises(ValueError):
          predictor_1.check_contributions(shap_values[:, :-1])
  
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 8 for calling the TestSmartPredictor obj's underlying member method code with example usage: obj.test_check_contributions() without return types