code: def get_decisionpath_df(decision_tree, observation, pos_label=1):
      """summarize the path through a DecisionTree for a specific observation.
  
      Args:
          decision_tree (DecisionTreeClassifier or DecisionTreeRegressor):
              a fitted DecisionTree model.
          observation ([type]): single row of data to display tree path for.
          pos_label (int, optional): label of positive class. Defaults to 1.
  
      Returns:
          pd.DataFrame: columns=['node_id', 'average', 'feature',
              'value', 'split', 'direction', 'left', 'right', 'diff']
      """
      nodes = decision_tree.predict_path(observation)
  
      decisiontree_df = pd.DataFrame(
          columns=[
              "node_id",
              "average",
              "feature",
              "value",
              "split",
              "direction",
              "left",
              "right",
              "diff",
          ]
      )
      if decision_tree.is_classifier():
  
          def node_pred_proba(node):
              return node.class_counts()[pos_label] / sum(
                  node.class_counts()
              )
  
          for node in nodes:
              if not node.isleaf():
                  decisiontree_df = append_dict_to_df(
                      decisiontree_df,
                      {
                          "node_id": node.id,
                          "average": node_pred_proba(node),
                          "feature": node.feature_name(),
                          "value": observation[node.feature_name()],
                          "split": node.split(),
                          "direction": "left"
                          if observation[node.feature_name()]
                          < node.split()
                          else "right",
                          "left": node_pred_proba(node.left),
                          "right": node_pred_proba(node.right),
                          "diff": node_pred_proba(node.left)
                          - node_pred_proba(node)
                          if observation[node.feature_name()]
                          < node.split()
                          else node_pred_proba(node.right)
                          - node_pred_proba(node),
                      },
                  )
  
      else:
  
          def node_mean(node):
              return decision_tree.tree_model.tree_.value[
                  node.id
              ].item()
  
          for node in nodes:
              if not node.isleaf():
                  decisiontree_df = append_dict_to_df(
                      decisiontree_df,
                      {
                          "node_id": node.id,
                          "average": node_mean(node),
                          "feature": node.feature_name(),
                          "value": observation[node.feature_name()],
                          "split": node.split(),
                          "direction": "left"
                          if observation[node.feature_name()]
                          < node.split()
                          else "right",
                          "left": node_mean(node.left),
                          "right": node_mean(node.right),
                          "diff": node_mean(node.left) - node_mean(node)
                          if observation[node.feature_name()]
                          < node.split()
                          else node_mean(node.right) - node_mean(node),
                      },
                  )
      return decisiontree_df
  
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 27 for calling a global function with example usage: get_decisionpath_df(decision_tree, observation, pos_label) and returns: decisiontree_df, unknown, decision_tree