Skip to content

Branch

A generic tree branch.

Parameters

  • children

    Child branches and/or leaves.

Attributes

  • height

    Distance to the deepest descendant.

  • n_branches

    Number of branches, including thyself.

  • n_leaves

    Number of leaves.

  • n_nodes

    Number of descendants, including thyself.

  • repr_split

    String representation of the split.

Methods

iter_bfs

Iterate over nodes in breadth-first order.

iter_branches

Iterate over branches in depth-first order.

iter_dfs

Iterate over nodes in depth-first order.

iter_edges

Iterate over edges in depth-first order.

iter_leaves

Iterate over leaves from the left-most one to the right-most one.

most_common_path

Return a tuple with the branch index and the child node related to the most traversed path.

Used in case the split feature is missing from an instance.

next

Move to the next node down the tree.

Parameters

  • x
to_dataframe

Build a DataFrame containing one record for each node.

traverse

Return the leaf corresponding to the given input.

Parameters

  • x
  • until_leaf – defaults to True
walk

Iterate over the nodes of the path induced by x.

Parameters

  • x
  • until_leaf – defaults to True