class_docstr: Unit test Smart Predictor class
class_docstr_tok: ["Unit","test","Smart","Predictor","class"]
docstr: Test add_input method from smart predictor with groups of features
docstr_tok: ["Test","add_input","method","from","smart","predictor","with","groups","of","features"]
code: def test_add_input_2(self):
      """
      Test add_input method from smart predictor with groups of features
      """
      ypred = self.df_1["y"]
      shap_values = self.clf_1.get_feature_importance(
          Pool(self.df_encoded_1), type="ShapValues"
      )
  
      predictor_1 = self.predictor_1_w_groups
      predictor_1.add_input(
          x=self.df_1[["x1", "x2"]], contributions=shap_values[:, :-1]
      )
      predictor_1_contrib = predictor_1.data["contributions"]
  
      assert all(
          attribute in predictor_1.data.keys()
          for attribute in [
              "x",
              "x_preprocessed",
              "x_postprocessed",
              "contributions",
              "ypred",
          ]
      )
  
      assert hasattr(predictor_1, "data_groups")
      assert all(
          attribute in predictor_1.data_groups.keys()
          for attribute in ["x_postprocessed", "contributions", "ypred"]
      )
  
      assert (
          predictor_1.data["x"].shape
          == predictor_1.data["x_preprocessed"].shape
      )
      assert all(
          feature in predictor_1.data["x"].columns
          for feature in predictor_1.data["x_preprocessed"].columns
      )
      assert predictor_1_contrib.shape == predictor_1.data["x"].shape
  
      predictor_1.add_input(ypred=ypred)
  
      assert "ypred" in predictor_1.data.keys()
      assert (
          predictor_1.data["ypred"].shape[0]
          == predictor_1.data["x"].shape[0]
      )
      assert all(
          predictor_1.data["ypred"].index == predictor_1.data["x"].index
      )
  
      print(predictor_1.data["contributions"].sum(axis=1).values)
  
      print(predictor_1.data_groups["contributions"])
  
      assert all(
          predictor_1.data_groups["contributions"]["group1"].values
          == predictor_1.data["contributions"].sum(axis=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 7 for calling the TestSmartPredictor obj's underlying member method code with example usage: obj.test_add_input_2() without return types