On 2012-04-02 03:07, Elizabeth Tseng wrote:
Hi,

I've just started using rpy/rpy2. I have a SVM model trained using the kernlab package. I stored the model in a R file called "MPDR.training_size2000.RData" (so if I call 'load' in R, the object 'model' is the trained model).

I'm trying to load the model through rpy2, then run predict() on it. My code is as follows:

import rpy2.rpy_classic as rpy
import rpy2.robjects as robj
rpy.set_default_mode(rpy.NO_CONVERSION)
model = rpy.r.load("MPDR.training_size2000.RData")
rpy.r.predict(model, <some data here>)


and I get the error:

no applicable method for 'predict' applied to an object of class "character"


It seems like I'm not loading the model correctly. What can be done?

The R function loads objects in R's "global environment"; what is returned by load() is the names/symbols of the objects loaded AFAIR. Your model is somewhere in R's global environment.

L.

PS: rpy2 has a more Python-like interface to that
http://rpy.sourceforge.net/rpy2/doc-2.2/html/robjects_serialization.html



Thanks,
--Elizabeth






------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure


_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to