sato9hara / defragTrees

Python code for tree ensemble interpretation
MIT License
83 stars 22 forks source link

Example lgb failing with IndexError #3

Closed MaksimMisin closed 11 months ago

MaksimMisin commented 5 years ago

I can't reproduce LightGBM example:

> python exmaple_lgb.py

...(training outputs)...

----- Found Rules -----
Traceback (most recent call last):
  File "example_lgb.py", line 51, in <module>
    print(mdl)
  File "../defragTrees.py", line 87, in __str__
    box, vmin, vmax = self.__r2box(self.rule_[i], self.dim_)
  File "../defragTrees.py", line 187, in __r2box
    box[1, rr[0]-1] = np.minimum(box[1, rr[0]-1], rr[2])
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

I am using python 3.7 with the following packages:

lightgbm==2.2.2
numpy==1.15.4
pandas==0.23.4
scikit-learn==0.20.1
scipy==1.1.0

On the related note, could you please add requirements.txt file.

sato9hara commented 5 years ago

Thanks you for pointing out the bug. I found that defragTrees.py was trying to assign float values to the array indices. The bug is now fixed.