# which neural network to use?

I have explored this site for the answer but could not find what i was looking for. My problem is i have data containing many variables (22) that are continuos and categorical and my output has two levels 1(present) or 0 (absent). My questions are:

1) What type of library, for a neural network model, would be best for this type of data (nnet or neuralnet in r)

2) I have been told that this is a regression problem not a classification, however since my output only has two levels why is this regression and not classification?

Both packages neuralnet and nnet can be used for your task.

If you receive warnings on you are running regression but not classification, try to change the type for the response variable using function factor.

library(nnet)
library(mlbench)

set.seed(0)
d=mlbench.2dnormals(500)
plot(d)
d=data.frame(x1=d$x[,1],x2=d$x[,2],y=d$classes) # nnet function from nnet package fit1<-nnet(y~.,data=d,size=10) fit1 # nnet from neuralnet package library(neuralnet) d$y=as.numeric(d\$y)
fit2<-neuralnet(y~x1+x2,data=d,hidden=10)
fit2

• Thank you, however when i convert my response variable into a factor in the neuralnet package i get an error message stating that i am using the wrong model for classification ? – Martin May 19 '17 at 17:08
• @Martin hard for me to see what's happening with limited information here. But I will give you 2 examples on each package by revising answer. – Haitao Du May 19 '17 at 17:13
• Thank you for the example. This works fine for me and i can do both types of models from each package with no problem. however, when i try to cross validate this, under the caret package, i get the error message, "wrong model for classification", even when i convert the response variable to a factor. This is where my confusion comes from and why i ask the question, "is this is a classification or a regression problem", as it seems running the 'neuralnet' package with a factor as the response variable does not work? – Martin May 19 '17 at 17:18
• @Martin that seems to be off topic for CV. – Haitao Du May 19 '17 at 17:21
• Thanks for the heads up, this could be why i cannot find the answer to this problem anywhere. – Martin May 19 '17 at 17:22