The way I am currently using neural net is that it predicts one output point from many input points. More specifically, I run the below.
nn <- neuralnet(
as.formula(a ~ c + d),
data=Z, hidden=c(3,2), err.fct="sse", act.fct=custom,
linear.output=TRUE, rep=5)
Here, if Z is a matrix of columns with names a, b, c, it will predict one point from one row in column a from the corresponding points in rows c and d. (The vertical dimension is used as samples for training.)
Suppose there's also a column b. I am wondering if there's a way to predict both, a and b, from c and d? I've tried
as.formula(a+b ~ c+d)
but that does not appear to work.
Any ideas?
My bad, it works nicely using a + b ~ c + d. I thought the function did not accept this input (as it crashed many times), but there must have been another problem which is now gone that I cleaned it all up.
nn <- neuralnet(as.formula(a + b ~ c + d),
data=Z, hidden=c(3,2), err.fct="sse", act.fct=custom,
linear.output=TRUE, rep=5)
Works beautifully and returns two point (or two column) output! Neat.
Examples from neuralnet
, the format works :)
AND <- c(rep(0,7),1)
OR <- c(0,rep(1,7))
binary.data <- data.frame(expand.grid(c(0,1), c(0,1), c(0,1)), AND, OR)
print(net <- neuralnet(AND+OR~Var1+Var2+Var3, binary.data, hidden=0,
rep=10, err.fct="ce", linear.output=FALSE))