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

NullPointerException when converting a binary classifier with converter-executable-1.0-SNAPSHOT.jar #4

Closed travisbrady closed 7 years ago

travisbrady commented 7 years ago

I get the error below when trying to convert a saved booster.

The LGBM model file is here: https://gist.github.com/travisbrady/3408dedf1a8217a32eb859337b354648

$ java -jar converter-executable-1.0-SNAPSHOT.jar --lgbm-input models/clf_2017_03_12data.lgb.txt --pmml-output lightgbm.pmml
Exception in thread "main" java.lang.NullPointerException
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838)
    at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    at java.lang.Double.parseDouble(Double.java:538)
    at org.jpmml.lightgbm.Section.getDouble(Section.java:54)
    at org.jpmml.lightgbm.GBDT.load(GBDT.java:76)
    at org.jpmml.lightgbm.LightGBMUtil.loadGBDT(LightGBMUtil.java:56)
    at org.jpmml.lightgbm.LightGBMUtil.loadGBDT(LightGBMUtil.java:48)
    at org.jpmml.lightgbm.Main.run(Main.java:110)
    at org.jpmml.lightgbm.Main.main(Main.java:103)

Interestingly the PMML converter that comes with Lightgbm runs without crashing but generates a file without a single tree in it.

Other details: Model created with lgb Python bindings

$ java -version
java version "1.8.0_71"
Java(TM) SE Runtime Environment (build 1.8.0_71-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.71-b15, mixed mode)
vruusmann commented 7 years ago

Looks like LightGBM has updated the model data format lately.

The JPMML-LightGBM library is attempting to load the value of the sigmoid parameter from the "header" section, but it is not there anymore: https://github.com/jpmml/jpmml-lightgbm/blob/master/src/main/java/org/jpmml/lightgbm/GBDT.java#L76

travisbrady commented 7 years ago

Did it move to the end of the objective param?

In my txt model: https://gist.github.com/travisbrady/3408dedf1a8217a32eb859337b354648#file-clf_2017_03_12data-lgb-txt-L6

vruusmann commented 7 years ago

Did it move to the end of the objective param?

Indeed, looks like LightGBM has "inlined" objective function-specific parameters to reduce clutter in the "header" section.

I can spot some other changes in the model data format. For example, tree sections specify the has_categorical parameter, which wasn't there ~1 month ago.