parrt / dtreeviz

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

AttributeError: 'Rectangle' object has no attribute 'patches' #280

Open tlapusan opened 1 year ago

tlapusan commented 1 year ago

We introduced this fix here : https://github.com/parrt/dtreeviz/pull/266, when a node will not contain samples from each label.

By filtering out those labels, we can have the situation when only a single label will be in a node, which will raise this error : AttributeError: 'Rectangle' object has no attribute 'patches'

baligoyem commented 1 year ago

After last update, errors below often occur in my case. ValueError: The 'color' keyword argument must have one color per dataset, but 1 datasets and 0 colors were provided, AttributeError: 'Rectangle' object has no attribute 'patches' ValueError: need at least one array to concatenate

I think that these errors completely depend on the structure of the tree built.

Moreover, "try-except pass" structure doesn't work in the error of concatenation and I can't ignore the error message below.

image

tlapusan commented 1 year ago

@baligoyem what version of the library are you using?

tlapusan commented 1 year ago

@baligoyem and also which type of visualisation are you trying to make ? Your screenshot seems to be from path.py module from matplotlib library..

@parrt I think we don't have the latest PRs from dev into master and releases on pipy repository.

baligoyem commented 1 year ago

@tlapusan

matplotlib==3.5.3 dtreeviz==2.2.0 lightgbm==3.3.3

I always get these errors when I try to build a dtreeviz model tree using LightGBM algorithm. There is no problem with sklearn trees.

tlapusan commented 1 year ago

@baligoyem we just made a new release 2.2.1. Can you check if it solves your issue ? thanks