Search code examples
machine-learningdata-visualizationdecision-treexgboostdtreeviz

Subtrees visualization in dtreeviz


I am new to dtreeviz. I am struggling with a very deep decision tree that is very difficult to visualize (overfitting is not an issue for my task). I would like to know if there is a way to visualize only some nodes of the three (e.g., first 5 nodes).

Thanks!

from dtreeviz.models.xgb_decision_tree import ShadowXGBDTree
from dtreeviz import trees 

xgb_shadow = ShadowXGBDTree(xgb_model_reg, 0, d.loc[:, d.columns != output_quantitativi[0]], 
                             d[output_quantitativi[0]], d.loc[:, d.columns != output_quantitativi[0]].columns,output_quantitativi[0])

trees.dtreeviz(xgb_shadow)

Solution

  • for dtreeviz method it was just added the parameter depth_range_to_display, which allows you to specify a range of tree levels that you want to display.

    enter image description here

    For viz_leaf_samples() you can play with min_samples and max_samples values if the tree contains a lot of leaf nodes.