code: def _get_node_info(tree, node_id):
      # type: (...) -> NodeInfo
      is_leaf = tree.children_left[node_id] == _tree.TREE_LEAF
      value = _node_value(tree, node_id)
      node = NodeInfo(
          id=node_id,
          is_leaf=is_leaf,
          value=list(value),
          value_ratio=list(value / value.sum()),
          impurity=tree.impurity[node_id],
          samples=tree.n_node_samples[node_id],
          sample_ratio=tree.n_node_samples[node_id]
          / tree.n_node_samples[0],
      )
      if not is_leaf:
          node.feature_id = tree.feature[node_id]
          node.threshold = tree.threshold[node_id]
          node.left = _get_node_info(tree, tree.children_left[node_id])
          node.right = _get_node_info(
              tree, tree.children_right[node_id]
          )
      return node
  
file_path: eli5/eli5/sklearn/treeinspect.py
imports: from __future__ import absolute_import, division
  from sklearn.base import ClassifierMixin
  from sklearn.tree import _tree, export_graphviz
  from eli5.base import TreeInfo, NodeInfo
label_desc: Use image node_id 5 for calling a global function with example usage: _get_node_info(tree, node_id) and returns: node