Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert NeuralNet to PMML #45

Open
Clls1 opened this issue Sep 18, 2018 · 1 comment
Open

Convert NeuralNet to PMML #45

Clls1 opened this issue Sep 18, 2018 · 1 comment

Comments

@Clls1
Copy link

Clls1 commented Sep 18, 2018

Hello I'm trying to extract a PMML from a model created with the neuralnet package but I have an error.
I belive its due to the target variable being "GOOD + BAD" because when I try with only one of them it runs ok. However, my target is a factor so I don't know how can I resolve this issue.

Thank you!

dfGoodBad=data.frame(V1=c(.2,.1,.2,.2,.4,.3),
                    V2=c(.9,.1,.4,.5,.5,.8),
                    TARGET=factor(c('GOOD','BAD','BAD','BAD','GOOD','GOOD')))

dfGoodBad$GOOD=ifelse(dfGoodBad$TARGET=='GOOD',1,0)
dfGoodBad$BAD=ifelse(dfGoodBad$TARGET=='BAD',1,0)

nn <- neuralnet(GOOD + BAD ~ V1+V2, data = dfGoodBad, algorithm = "rprop+", linear.output = F, hidden = 3)

library(r2pmml)
r2pmml(nn, "nn.pmml")

This is the error I get:

SEVERE: Failed to convert
java.lang.IllegalStateException
at org.jpmml.rexp.RVector.asScalar(RVector.java:56)
at org.jpmml.rexp.NNConverter.encodeSchema(NNConverter.java:58)
at org.jpmml.rexp.ModelConverter.encodePMML(ModelConverter.java:69)
at org.jpmml.rexp.Converter.encodePMML(Converter.java:39)
at org.jpmml.rexp.Main.run(Main.java:149)
at org.jpmml.rexp.Main.main(Main.java:97)

Exception in thread "main" java.lang.IllegalStateException
at org.jpmml.rexp.RVector.asScalar(RVector.java:56)
at org.jpmml.rexp.NNConverter.encodeSchema(NNConverter.java:58)
at org.jpmml.rexp.ModelConverter.encodePMML(ModelConverter.java:69)
at org.jpmml.rexp.Converter.encodePMML(Converter.java:39)
at org.jpmml.rexp.Main.run(Main.java:149)
at org.jpmml.rexp.Main.main(Main.java:97)
Error in .convert(tempfile, file, converter, converter_classpath, verbose) :
1

@vruusmann
Copy link
Member

nn <- neuralnet(GOOD + BAD ~ V1+V2)

Your analysis/interpretation is correct - the R2PMML package does not support multi-output (GOOD + BAD) neural network models. If you simplify the model to single output (either GOOD or BAD), then the conversion should succeed.

This is something that should be supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants