class_docstr: Unit test Smart Predictor class
class_docstr_tok: ["Unit","test","Smart","Predictor","class"]
docstr: Unit test for apply preprocessing method
docstr_tok: ["Unit","test","for","apply","preprocessing","method"]
code: def test_apply_preprocessing_1(
      self,
      check_consistency_model_label,
      check_consistency_model_features,
      check_preprocessing_options,
      check_model,
  ):
      """
      Unit test for apply preprocessing method
      """
      y = pd.DataFrame(data=[0, 1], columns=["y"])
      train = pd.DataFrame({"num1": [0, 1], "num2": [0, 2]})
      enc = ColumnTransformer(
          transformers=[
              (
                  "power",
                  skp.QuantileTransformer(n_quantiles=2),
                  ["num1", "num2"],
              )
          ],
          remainder="passthrough",
      )
      enc.fit(train, y)
      train_preprocessed = pd.DataFrame(
          enc.transform(train), index=train.index
      )
      clf = cb.CatBoostClassifier(n_estimators=1).fit(
          train_preprocessed, y
      )
  
      features_types = {
          features: str(train[features].dtypes)
          for features in train.columns
      }
      backend = ShapBackend(model=clf)
      columns_dict = {0: "num1", 1: "num2"}
      label_dict = {0: "Yes", 1: "No"}
      features_dict = {"num1": "city", "num2": "state"}
  
      check_preprocessing_options.return_value = True
      check_consistency_model_features.return_value = True
      check_consistency_model_label.return_value = True
      check_model.return_value = "classification", [0, 1]
  
      predictor_1 = SmartPredictor(
          features_dict,
          clf,
          columns_dict,
          backend,
          features_types,
          label_dict,
          enc,
      )
      predictor_1.data = {"x": None}
      predictor_1.data["x"] = train
      predictor_1.data[
          "x_preprocessed"
      ] = predictor_1.apply_preprocessing()
  
      output_preprocessed = predictor_1.data["x_preprocessed"]
      assert output_preprocessed.shape == train_preprocessed.shape
      assert [
          column in clf.feature_names_
          for column in output_preprocessed.columns
      ]
      assert all(train.index == output_preprocessed.index)
      assert all(
          [
              str(type_result) == str(train_preprocessed.dtypes[index])
              for index, type_result in enumerate(
                  output_preprocessed.dtypes
              )
          ]
      )
  
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 25 for calling the TestSmartPredictor obj's underlying member method code with example usage: obj.test_apply_preprocessing_1(check_consistency_model_label, check_consistency_model_features, check_preprocessing_options, check_model) without return types