When I follow along with the example here - https://github.com/jpmml/jpmml-xgboost - it all works fine, and the PMML document scores as I need it to. However when I try to accomplish the same thing with a multi class classification model it throws the following error:
Exception in thread "main" java.lang.IllegalArgumentException: multi:softprob
at org.jpmml.xgboost.Learner.load(Learner.java:66)
at org.jpmml.xgboost.XGBoostUtil.loadLearner(XGBoostUtil.java:34)
at org.jpmml.xgboost.Main.run(Main.java:92)
at org.jpmml.xgboost.Main.main(Main.java:85)
I am running "java -jar converter-executable-1.0-SNAPSHOT.jar --model-input xgboost.model --fmap-input xgboost.fmap --pmml-output xgboost.pmml" to produce this error. I have attached a sample of my dataset to see what it looks like.
Please advise on whether it is user error or whether {objective: "multi:softprob"} is not supported yet for xgboost in R.
> The JPMML-XGBoost library now supports both "multi:softmax" and
> "multi:softprob" objective functions:
> https://github.com/jpmml/jpmml-xgboost/commit/f1670f69109b4d1bceb8342c3a4309b9c534224a
Thanks very much for this! We do not have a good Java resource on my team so we hacked together a solution that allowed us to use the LocalTransformations functionality from the "pmml" R package together with jpmml's accurate implementation of the randomForest pmml conversion. I am excited to try out this new functionality.
Josh
The PMML file generated by the .jar file for a multi class xgboost model has a field at the bottom of PMML file like so:
<RegressionModel functionName="classification" normalizationMethod="simplemax">
<MiningSchema>
<MiningField name="MaxOption" usageType="target"/>
<MiningField name="transformedValue_0"/>
<MiningField name="transformedValue_1"/>
</MiningSchema>
<Output>
<OutputField name="probability_0" feature="probability" value="0"/>
<OutputField name="probability_1" feature="probability" value="1"/>
</Output>
<RegressionTable intercept="0.0" targetCategory="0">
<NumericPredictor name="transformedValue_0" coefficient="1.0"/>
</RegressionTable>
<RegressionTable intercept="0.0" targetCategory="1">
<NumericPredictor name="transformedValue_1" coefficient="1.0"/>
</RegressionTable>
</RegressionModel>
It has normalizationMethod "simpleMax".
When I try to use this PMML file to score requests, I get this error (only top of stack included):
"stack": [
"org.jpmml.evaluator.InvalidFeatureException: RegressionModel",
"at org.jpmml.evaluator.RegressionModelEvaluator.normalizeClassificationResult(RegressionModelEvaluator.java:337)",
"at org.jpmml.evaluator.RegressionModelEvaluator.computeBinomialProbabilities(RegressionModelEvaluator.java:264)",
"at org.jpmml.evaluator.RegressionModelEvaluator.evaluateClassification(RegressionModelEvaluator.java:159)",
Looking in RegressionModelEvaluator, I see the following code:
switch(regressionNormalizationMethod){
case NONE:
return value;
case SIMPLEMAX:
throw new InvalidFeatureException(regressionModel);
case SOFTMAX:
if(classes != 2){
throw new InvalidFeatureException(regressionModel);
}
// Falls through
case LOGIT:
return 1d / (1d + Math.exp(-value));
case PROBIT:
return NormalDistributionUtil.cumulativeProbability(value);
case CLOGLOG:
return 1d - Math.exp(-Math.exp(value));
case LOGLOG:
return Math.exp(-Math.exp(-value));
case CAUCHIT:
return 0.5d + (1d / Math.PI) * Math.atan(value);
default:
throw new UnsupportedFeatureException(regressionModel, regressionNormalizationMethod);
Am I reading this wrong, or is the default normalization method not supported?
Thanks!