# Trees¶

## Digging into the tree structure¶

`mlinsights.mltree.predict_leaves`

(*model*, *X*)

Returns the leave every observations of

Xfalls into.

`mlinsights.mltree.tree_structure.tree_find_common_node`

(*tree*, *i*, *j*, *parents* = None)

Finds the common node to nodes

iandj.

`mlinsights.mltree.tree_structure.tree_find_path_to_root`

(*tree*, *i*, *parents* = None)

Lists nodes involved into the path to find node

i.

`mlinsights.mltree.tree_structure.tree_node_parents`

(*tree*)

Returns a dictionary

`{node_id: parent_id}`

.

`mlinsights.mltree.tree_node_range`

(*tree*, *i*, *parents* = None)

Determines the ranges for a node all dimensions.

`nan`

means infinity.

`mlinsights.mltree.tree_leave_index`

(*model*)

Returns the indices of every leave in a tree.

`mlinsights.mltree.tree_leave_neighbors`

(*model*)

The function determines which leaves are neighbors. The method uses some memory as it creates creates a grid of the feature spaces, each split multiplies the number of cells by two.

## Experiments, exercise¶

`mlinsights.mltree.digitize2tree`

(*bins*, *right* = False)

Builds a decision tree which returns the same result as lambda x: numpy.digitize(x, bins, right=right) (see numpy.digitize).