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

NumberFormatException happens #8

Closed Alexkevin closed 6 years ago

Alexkevin commented 6 years ago

I tried the example you have provided with boston dataset. When I converted the model file to PMML, I got the following errors:

Exception in thread "main" java.lang.NumberFormatException: null
    at java.lang.Integer.parseInt(Integer.java:454)
    at java.lang.Integer.parseInt(Integer.java:527)
    at org.jpmml.lightgbm.Section.getInt(Section.java:46)
    at org.jpmml.lightgbm.Tree.load(Tree.java:74)
    at org.jpmml.lightgbm.GBDT.load(GBDT.java:97)
    at org.jpmml.lightgbm.LightGBMUtil.loadGBDT(LightGBMUtil.java:58)
    at org.jpmml.lightgbm.LightGBMUtil.loadGBDT(LightGBMUtil.java:50)
    at org.jpmml.lightgbm.Main.run(Main.java:122)
    at org.jpmml.lightgbm.Main.main(Main.java:115)

How to deal with it ? I attach my model file lightgbm.txt

Thanks!

vruusmann commented 6 years ago

What is your LightGBM version (release number, or the commit id)?

I attach my model file

The Tree=0 section (lines 11 to 26) doesn't contain the num_cat attribute. This attribute is definitely present in LightGBM v2.0.7 models, but may be missing in newer ones.

The workaround would be to wrap this attribute lookup into some guarding code, such as:

if(section.contains("num_cat")){
    this.num_cat_ = section.getInt("num_cat");
} else {
    this.num_cat_ = 0;
}
Alexkevin commented 6 years ago

@vruusmann the version is 2.0.1 Is it too older ? I will try to update it

Alexkevin commented 6 years ago

The problem is the version of gbm is too older. I updated it to 2.0.10 and works well Many thanks