Thanks! That got me there, with only the following minor adjustments (recorded 
for posterity):

First, it's nnet.predict_nnet() (not nnet.predict())

Also, I had to convert my pandas DataFrame to an R data.frame this way:

import pandas.rpy.common as com
r_df = com.convert_to_r_dataframe(pd_df)

-Alessandro

From: Laurent Gautier <lgaut...@gmail.com<mailto:lgaut...@gmail.com>>
Date: Monday, December 2, 2013 3:45 PM
To: Alessandro 
<alessandro.gaglia...@glassdoor.com<mailto:alessandro.gaglia...@glassdoor.com>>
Cc: "RPy help, support and design discussion list" 
<rpy-list@lists.sourceforge.net<mailto:rpy-list@lists.sourceforge.net>>
Subject: Re: [Rpy] load nnet in rpy2

Ah, yes. Good you did. The licensing had all the attention.

The following is completely untested, but should get you going (and with some 
luck, just work as it is)

from rpy2.robjects.packages import importr
base = importr('base')
nnet = importr('nnet')
# load: the side effect is to populate the R global environment
# with whatever in the file. I am assuming that 'err_net' comes from it.
base.load('err_net.RData')
from rpy2.robjects import globalenv
err_net = globalenv['err_net']
y = nnet.predict(err_net, x)


On 12/02/2013 01:47 PM, Alessandro Gagliardi wrote:
I didn't get a response last week so I figured I should try again:

How do I load a nnet model from a file in rpy2?

Thanks,
-Alessandro

From: Alessandro 
<alessandro.gaglia...@glassdoor.com<mailto:alessandro.gaglia...@glassdoor.com>>
Date: Friday, November 22, 2013 4:27 PM
To: "rpy-list@lists.sourceforge.net<mailto:rpy-list@lists.sourceforge.net>" 
<rpy-list@lists.sourceforge.net<mailto:rpy-list@lists.sourceforge.net>>
Subject: load nnet in rpy2

Hi all,

I created a nnet model called err_net in R that I've saved in err_net.RData 
which I'd like to employ programmatically in a python module. If I were to do 
it in IPython Notebook using rmagic I might have a cell that look something 
like:

%%R -i x -o y
library(nnet)
load('err_net.RData')
y <- predict(err_net, x)

What would be the best way to do this without relying on magics?

Thanks in advance,
-Alessandro



------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk



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

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to