Error while converting GBM model to PMML in R

102 views
Skip to first unread message

mohit gupta

unread,
Jan 30, 2017, 11:13:32 AM1/30/17
to Java PMML API
Hi ,

I am trying to convert GBM model into PMML using r2pmml package. I am getting below error:


Jan 30, 2017 11:07:13 AM org.jpmml.rexp.Main run
SEVERE: Failed to convert
java.lang.IllegalStateException
at org.jpmml.rexp.RVector.asScalar(RVector.java:48)
at org.jpmml.rexp.GBMConverter.encodeSchema(GBMConverter.java:72)
at org.jpmml.rexp.ModelConverter.encodePMML(ModelConverter.java:74)
at org.jpmml.rexp.ModelConverter.encodePMML(ModelConverter.java:70)
at org.jpmml.rexp.Main.run(Main.java:149)
at org.jpmml.rexp.Main.main(Main.java:97)


Error in .convert(tempfile, file, ...) : 1
In addition: Warning message:


Can anyone help me with that ?


Villu Ruusmann

unread,
Jan 30, 2017, 2:43:48 PM1/30/17
to Java PMML API
Hi Mohit,

>
> I am trying to convert GBM model into PMML using r2pmml package. I am getting below error:
>
> Jan 30, 2017 11:07:13 AM org.jpmml.rexp.Main run
> SEVERE: Failed to convert
> java.lang.IllegalStateException
> at org.jpmml.rexp.RVector.asScalar(RVector.java:48)
> at org.jpmml.rexp.GBMConverter.encodeSchema(GBMConverter.java:72)
>

This exception is thrown, because the internal structure of your 'gbm'
object does not meet expectations. Specifically, the value of
'response.name' attribute is not a string, but something else:
https://github.com/jpmml/jpmml-r/blob/master/src/main/java/org/jpmml/rexp/GBMConverter.java#L72

Can you check what it is? Did you tweak this attribute value manually,
or are you using some very old/very new/customized version of the R
gbm package?

Can you execute the following R script?
<R>
library("gbm")
library("r2pmml")

data(iris)
iris.gbm = gbm(Species ~ ., data = iris)
r2pmml(iris.gbm, "gbm.pmml")
print(iris.gbm$response.name)
</R>

Here, the statement "print(iris.gbm$response.name)" should print out a
string value "Species".


VR

mohit gupta

unread,
Jan 30, 2017, 4:10:16 PM1/30/17
to Java PMML API

Wow Villu, Thanks a lot, I

It worked now. Response name was the actual problem. I was using dataset$dependentvariable instead of just dependentvariable while creating the model. Thanks a ton !!!

Reply all
Reply to author
Forward
0 new messages