lightgbm.plot_tree — LightGBM 4.6.0.99 documentation (original) (raw)

LightGBM

lightgbm.plot_tree(booster, ax=None, tree_index=0, figsize=None, dpi=None, show_info=None, precision=3, orientation='horizontal', example_case=None, **kwargs)[source]

Plot specified tree.

Each node in the graph represents a node in the tree.

Non-leaf nodes have labels like Column_10 <= 875.9, which means “this node splits on the feature named “Column_10”, with threshold 875.9”.

Leaf nodes have labels like leaf 2: 0.422, which means “this node is a leaf node, and the predicted value for records that fall into this node is 0.422”. The number (2) is an internal unique identifier and doesn’t have any special meaning.

Note

It is preferable to use create_tree_digraph() because of its lossless quality and returned objects can be also rendered and displayed directly inside a Jupyter notebook.

Parameters:

Returns:

ax – The plot with single tree.

Return type:

matplotlib.axes.Axes