parrt / dtreeviz

A python library for decision tree visualization and model interpretation.
MIT License
2.94k stars 331 forks source link

Visualisation error when a node will contains samples from only one class (sklearn) #283

Closed tlapusan closed 1 year ago

tlapusan commented 1 year ago

Since version 0.19 (which is a pretty old one..) , the min_impurity_decrease defaults to 0.0, which means that we can have split nodes (pure nodes) with samples belonging to only one class. Ex.

Screenshot 2023-04-02 at 12 31 14

In this scenario, the actual code will fails for hist, bins, barcontainers = ax.hist(X_hist,.... because for a node with samples from only one class will return a Rectangle instead of a list of BarContainer.