class_docstr: This object adapts decision trees constructed by the various libraries such as scikit-learn's and XGBoost's
  DecisionTree(Regressor|Classifier) to dtreeviz.  As part of the construction process, the samples
  considered at decision and leaf nodes are saved as a big dictionary for use by the nodes.
  
  The decision trees for classifiers and regressors from scikit-learn and
  XGBoost etc... are built for efficiency, not ease of tree walking. This class
  wraps all of that information in an easy-to-use and consistent interface
  that hides the details of the various decision tree libraries.
  
  Field leaves is list of shadow leaf nodes.
  Field internal is list of shadow non-leaf nodes.
  Field root is the shadow tree root.
class_docstr_tok: ["This","object","adapts","decision","trees","constructed","by","the","various","libraries","such","as","scikit-learn","'s","and","XGBoost's","DecisionTree","(","Regressor|Classifier",")","to","dtreeviz",".","As","part","of","the","construction","process",",","the","samples","considered","at","decision","and","leaf","nodes","are","saved","as","a","big","dictionary","for","use","by","the","nodes",".","The","decision","trees","for","classifiers","and","regressors","from","scikit-learn","and","XGBoost","etc","...","are","built","for","efficiency",",","not","ease","of","tree","walking",".","This","class","wraps","all","of","that","information","in","an","easy-to-use","and","consistent","interface","that","hides","the","details","of","the","various","decision","tree","libraries",".","Field","leaves","is","list","of","shadow","leaf","nodes",".","Field","internal","is","list","of","shadow","non-leaf","nodes",".","Field","root","is","the","shadow","tree","root","."]
docstr: Get an internal representation of the tree obtained from a specific library
docstr_tok: ["Get","an","internal","representation","of","the","tree","obtained","from","a","specific","library"]
code: def get_shadow_tree(
      tree_model,
      X_train,
      y_train,
      feature_names,
      target_name,
      class_names=None,
      tree_index=None,
  ):
      """Get an internal representation of the tree obtained from a specific library"""
      # Sanity check
      if isinstance(X_train, pd.DataFrame):
          nancols = X_train.columns[
              X_train.isnull().any().values
          ].tolist()
          if len(nancols) > 0:
              raise ValueError(
                  f"dtreeviz does not support NaN (see column(s) {', '.join(nancols)})"
              )
      elif isinstance(X_train, np.ndarray):
          nancols = (
              np.where(pd.isnull(X_train).any(axis=0))[0]
              .astype(str)
              .tolist()
          )
          if len(nancols) > 0:
              raise ValueError(
                  f"dtreeviz does not support NaN (see column index(es) {', '.join(nancols)})"
              )
  
      """
          To check to which library the tree_model belongs we are using string checks instead of isinstance()
          because we don't want all the libraries to be installed as mandatory, except sklearn.
          """
      if hasattr(tree_model, "get_booster"):
          # scikit-learn wrappers XGBClassifier and XGBRegressor allow you to
          # extract the underlying xgboost.core.Booster with the get_booster() method:
          tree_model = tree_model.get_booster()
      if isinstance(tree_model, ShadowDecTree):
          return tree_model
      elif isinstance(
          tree_model,
          (
              sklearn.tree.DecisionTreeRegressor,
              sklearn.tree.DecisionTreeClassifier,
          ),
      ):
          from dtreeviz.models import sklearn_decision_trees
  
          return sklearn_decision_trees.ShadowSKDTree(
              tree_model,
              X_train,
              y_train,
              feature_names,
              target_name,
              class_names,
          )
      elif str(type(tree_model)).endswith("xgboost.core.Booster'>"):
          from dtreeviz.models import xgb_decision_tree
  
          return xgb_decision_tree.ShadowXGBDTree(
              tree_model,
              tree_index,
              X_train,
              y_train,
              feature_names,
              target_name,
              class_names,
          )
      elif str(type(tree_model)).endswith(
          "pyspark.ml.classification.DecisionTreeClassificationModel'>"
      ) or str(type(tree_model)).endswith(
          "pyspark.ml.regression.DecisionTreeRegressionModel'>"
      ):
          from dtreeviz.models import spark_decision_tree
  
          return spark_decision_tree.ShadowSparkTree(
              tree_model,
              X_train,
              y_train,
              feature_names,
              target_name,
              class_names,
          )
      elif "lightgbm.basic.Booster" in str(type(tree_model)):
          from dtreeviz.models import lightgbm_decision_tree
  
          return lightgbm_decision_tree.ShadowLightGBMTree(
              tree_model,
              tree_index,
              X_train,
              y_train,
              feature_names,
              target_name,
              class_names,
          )
      elif any(
          tf_model in str(type(tree_model))
          for tf_model in [
              "tensorflow_decision_forests.keras.RandomForestModel",
              "tensorflow_decision_forests.keras.GradientBoostedTreesModel",
          ]
      ):
          from dtreeviz.models import tensorflow_decision_tree
  
          return tensorflow_decision_tree.ShadowTensorflowTree(
              tree_model,
              tree_index,
              X_train,
              y_train,
              feature_names,
              target_name,
              class_names,
          )
      else:
          raise ValueError(
              f"Tree model must be in (DecisionTreeRegressor, DecisionTreeClassifier, "
              "xgboost.core.Booster, lightgbm.basic.Booster, pyspark DecisionTreeClassificationModel, "
              f"pyspark DecisionTreeClassificationModel, tensorflow_decision_forests.keras.RandomForestModel, "
              f"tensorflow_decision_forests.keras.GradientBoostedTreesModel) "
              f"but you passed a {tree_model.__class__.__name__}!"
          )
  
imports: from abc import ABC, abstractmethod
  from numbers import Number
  from typing import List, Tuple, Mapping
  import numpy
  import pandas
  import sklearn
  from dtreeviz import utils
label_desc: Use image node_id 38 for calling the ShadowDecTree obj's underlying member method code with example usage: obj.get_shadow_tree(tree_model, X_train, y_train, feature_names, target_name, class_names, tree_index) and returns: tree_model, sklearn_decision_trees, xgb_decision_tree, spark_decision_tree, lightgbm_decision_tree, tensorflow_decision_tree