1

I've successfully created the model in RStudio using nnet.
But now I need to code it up in Java. I presume I could take the weights (wts) and build up the equations necessary for the activation functions, but I hope that someone has already written a function to do this.

How do people typically take their R model and implement them in C, Java, etc?

str(mynn) gives:

List of 18
$ n            : num [1:3] 1 2 1
    $ nunits       : int 5
$ nconn        : num [1:6] 0 0 0 2 4 7
    $ conn         : num [1:7] 0 1 0 1 0 2 3
$ nsunits      : num 4
    $ decay        : num 0.02
$ entropy      : logi FALSE
    $ softmax      : logi FALSE
$ censored     : logi FALSE
    $ value        : num 26466497
$ wts          : num [1:7] 6.422 -0.433 -11.771 2.086 -12001.039 ...
    $ convergence  : int 0

etc...

Perhaps this has been asked before, but hours of google searches has not revealed the answer.

Thank you for your help. I greatly appreciate it.

1 Answer 1

0

One approach is to use PMML. The CRAN package pmml supports exporting nnet models:

library(caret)
library(nnet)
library(pmml)

model <- train(
  Sepal.Length~., iris, 
  method='nnet', trace=FALSE, 
  trControl=trainControl(verboseIter=TRUE))
pmml(model$finalModel)
2
  • Thank you so much Zach! The pmml is much more understandable than the str() output and I see there are libraries in Java to consume that format. :)
    – Chris
    Mar 5, 2015 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.