File: nnet.py

package info (click to toggle)
rpy 1.0.3-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 636 kB
  • ctags: 774
  • sloc: ansic: 2,139; python: 1,591; makefile: 119; sh: 73
file content (29 lines) | stat: -rw-r--r-- 612 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from rpy import *

# avoid automatic conversion
set_default_mode(NO_CONVERSION)


r.library("nnet")
model = r("Fxy~x+y")

df = r.data_frame(x = r.c(0,2,5,10,15)
                   ,y = r.c(0,2,5,8,10)
                   ,Fxy = r.c(0,2,5,8,10))

NNModel = r.nnet(model, data = df
                  , size =10, decay =1e-3
                  , lineout=True, skip=True
                  , maxit=1000, Hess =True)

XG = r.expand_grid(x = r.seq(0,7,1), y = r.seq(0,7,1))
x = r.seq(0,7,1)
y = r.seq(0,7,1)


# turn automatic conversion back on
set_default_mode(BASIC_CONVERSION)

fit = r.predict(NNModel,XG)
print fit