code: def guess_shap(model):
      """guesses which SHAP explainer to use for a particular model, based
      on str(type(model)). Returns 'tree' for tree based models such as
      RandomForest and XGBoost that need shap.TreeExplainer, and 'linear'
      for linear models such as LinearRegression or Elasticnet that can use
      shap.LinearExplainer.
  
      Args:
          model: a fitted (sklearn-compatible) model
  
      Returns:
          str: {'tree', 'linear', None}
      """
      tree_models = [
          "RandomForestClassifier",
          "RandomForestRegressor",
          "DecisionTreeClassifier",
          "DecisionTreeRegressor",
          "ExtraTreesClassifier",
          "ExtraTreesRegressor",
          "GradientBoostingClassifier",
          "GradientBoostingRegressor",
          "HistGradientBoostingClassifier",
          "HistGradientBoostingRegressor",
          "XGBClassifier",
          "XGBRegressor",
          "LGBMClassifier",
          "LGBMRegressor",
          "CatBoostClassifier",
          "CatBoostRegressor",
          "NGClassifier",
          "NGBRegressor",
          "GBTClassifier",
          " GBTRegressor",
          "IsolationForest",
      ]
      linear_models = [
          "LinearRegression",
          "LogisticRegression",
          "Ridge",
          "Lasso",
          "ElasticNet",
          "SGDClassifier",
      ]
  
      skorch_models = [
          "skorch.net.NeuralNet",
          "skorch.regressor.NeuralNetRegressor",
          "skorch.classifier.NeuralNetClassifier",
          "skorch.classifier.NeuralNetBinaryClassifier",
      ]
  
      for tree_model in tree_models:
          if str(type(model)).endswith(tree_model + "'>"):
              return "tree"
  
      for lin_model in linear_models:
          if str(type(model)).endswith(lin_model + "'>"):
              return "linear"
  
      for skorch_model in skorch_models:
          if str(type(model)).endswith(skorch_model + "'>"):
              return "skorch"
  
      return None
  
imports: from functools import partial
  import re
  from collections import Counter
  from typing import List, Union
  import warnings
  import numpy
  import pandas
  from pandas.api.types import is_numeric_dtype, is_categorical_dtype
  from dtreeviz.trees import ShadowDecTree
  from sklearn.metrics import make_scorer
  from sklearn.base import clone
  from sklearn.pipeline import Pipeline
  from sklearn.model_selection import KFold, StratifiedKFold
  from joblib import Parallel, delayed
label_desc: Use image node_id 3 for calling a global function with example usage: guess_shap(model) and returns: None, str, str, str