I got PMML file of Gradient Boosting Model from KNIME and tried to use it in Java with JPMML.
My GBM model works fine in KNIME, but once I execute it in my Java module, I got the error log below(It’s the first line of error logs).
“org.jpmml.evaluator.TypeCheckException: Expected double value, got string value”
I checked all the node tags and output field tag in PMML file, but there is no syntax, datatype mismatching error (I couldn’t share the contents of PMML file due to security issue).
And I found a discussion about this on Nov 23, 2018.
In the discussion, it is a KNIME problem and a guy who is one of the KNIME developers said that they are looking to fix it.
I would appreciate if someone helps me with this.
As you may have read in the Github issue, this really is a bug in KNIME that we are aware of and will fix as soon as possible. In the meantime all I can suggest is that you manually edit the PMML in order to make it valid. The problem is that for Gradient Boosted Trees for classification we internally use regression trees to predict the logits of a softmax. In those regression trees the target field is obviously a number, while the target of the overall model is a string. Hence the error message you got. To fix this, it may be enough to not explicitly specify the target field in the regression models and let JPMML figure that out. Can you remove all
MiningField elements with
usageType="target" in the
MiningSchema of the
TreeModel-Elements? As XPath that should be something like:
Please let me know if this fixes the problem for usage with JPMML.
Thanks for your feedback.
I did remove all the elements that you’ve mentioned and make sure that types are correct.
Once I execute it, the error that I mentioned was gone, but, result was null.
I think there was no target field because I removed all the elements that related to “Target” in PMML file.
Do you have any idea about this?
And, here’s another questions.
If I try to use another model (e.g. logistic regression) instead of using tree model, does that work fine in Java without any modification to PMML file?
Thanks for your time and look forward to hearing from you.
did you also remove the target in the final RegressionModel that calculates the class? Because there it should stay, I think. It’s rather strange that JPMML returns null when the PMML document seems to be valid.
Concerning your other question: Do you mean replacing the GBT model with logistic regression or replacing the trees inside the GBT? I think a simple logistic regression model should work with JPMML, it is not as powerful as a GBT model, though.
I did remove the target in the final RegressionModel . I fixed it, then it works!
For my another question, I meant replacing GBT to a simple logistic regression model. I agree with you, it wouldn’t be as good as GBT.
Really appreciate your valuable feedback.