code: def make_stump(
      node_no,
      tree_struct,
      parent_stump,
      is_right_child,
      normalize=False,
  ):
      """
      Create a single local decision stump corresponding to a node in a
      scikit-learn tree structure object. The nonzero values of the stump are
      chosen so that the vector of local decision stump values over the training
      set (used to fit the tree) is orthogonal to those of all ancestor nodes.
  
      Parameters
      ----------
      node_no: int
          The index of the node
      tree_struct: object
          The scikit-learn tree object
      parent_stump: LocalDecisionStump object
          The local decision stump corresponding to the parent of the node in q
          uestion
      is_right_child: bool
          True if the new node is the right child of the parent node, False
          otherwise
      normalize: bool
          Flag. If set to True, then divide the nonzero function values by
          sqrt(n_samples in node) so that the vector of function values on the
          training set has unit norm. If False, then do not divide, so that the
          vector of function values on the training set has norm equal to
          n_samples in node.
  
      Returns
      -------
  
      """
      # Get features, thresholds and signs for ancestors
      if parent_stump is None:  # If root node
          a_features = []
          a_thresholds = []
          a_signs = []
      else:
          a_features = parent_stump.a_features + [parent_stump.feature]
          a_thresholds = parent_stump.a_thresholds + [
              parent_stump.threshold
          ]
          a_signs = parent_stump.a_signs + [is_right_child]
      # Get indices for left and right children of the node in question
      left_child = tree_struct.children_left[node_no]
      right_child = tree_struct.children_right[node_no]
      # Get quantities relevant to the node in question
      feature = tree_struct.feature[node_no]
      threshold = tree_struct.threshold[node_no]
      left_size = tree_struct.weighted_n_node_samples[left_child]
      right_size = tree_struct.weighted_n_node_samples[right_child]
      parent_size = tree_struct.weighted_n_node_samples[node_no]
      normalization = parent_size if normalize else 1
      left_val = -np.sqrt(right_size / (left_size * normalization))
      right_val = np.sqrt(left_size / (right_size * normalization))
  
      return LocalDecisionStump(
          feature,
          threshold,
          left_val,
          right_val,
          a_features,
          a_thresholds,
          a_signs,
      )
  
file_path: imodels/imodels/importance/local_stumps.py
imports: import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: make_stump(node_no, tree_struct, parent_stump, is_right_child, normalize) and returns: LocalDecisionStump