On Thu, 16 Oct 2008, Paulo Cortez wrote:

Hi,

I want to save a RWeka model into a file, in order to retrive it latter with a load function.

See this example:

library(RWeka)

NB <- make_Weka_classifier("weka/classifiers/bayes/NaiveBayes")
model<-NB(formula,data=data,...) # does not run but you get the idea

save(model,file="model.dat") # simple save R command
# ...
load("model.dat") # load the model from the previously saved file...
model # should work but I get instead this error:
Error in .jcall(x$classifier, "S", "toString") :
 RcallMethod: attempt to call a method of a NULL object.

What is wrong and how can I solve this problem?

The R object is just a reference to the corresponding object on the Java side (in Weka). When you close R, the Java/Weka session is also closed and the model is gone. Thus, when you load the object again in a new session, you only have a reference to a Java object that does not live anymore.
Z

Regards,
--
Paulo Alexandre Ribeiro Cortez  (PhD, MSc)
Lecturer (Prof. Auxiliar) at the Department of Information Systems (DSI)
University of Minho, Campus de AzurÈm, 4800-058 Guimaraes, Portugal
http://www.dsi.uminho.pt/~pcortez +351253510313 Fax:+351253510300

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to