jpmml / jpmml-lightgbm

Java library and command-line application for converting LightGBM models to PMML
GNU Affero General Public License v3.0
174 stars 58 forks source link

categorical features size when some are not in trees #36

Closed yairdata closed 4 years ago

yairdata commented 4 years ago

i am getting the following exception on conversion of the LGBM model which i supplied the categorical_feature parameter to :

Exception in thread "main" java.lang.IllegalArgumentException
        at org.jpmml.lightgbm.GBDT.encodeSchema(GBDT.java:296)
        at org.jpmml.lightgbm.GBDT.encodePMML(GBDT.java:381)
        at org.jpmml.lightgbm.Main.run(Main.java:132)
        at org.jpmml.lightgbm.Main.main(Main.java:118)

i think from looking at the code that the reason is that pandasCategoryIndex is incremented only if it appears in one of the trees , so in my case some of them are not , so the size of the pandas_categorical (that have all of the supplied categorical features ) doesnt match the calculated size (according to the tree appearance).

yairdata commented 4 years ago

ok, found the issue - it has to be with counting None featureInfo's with pandasCategoryIndex , i am not sure why it happens. when i removed all the None's columns from the model everything worked.

vruusmann commented 4 years ago

Need a reproducible example to start looking into this issue.

vruusmann commented 4 years ago

Closing as not reproducible.