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?


1 Answer 1


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.



# nnet function from nnet package

# nnet from neuralnet package
  • $\begingroup$ 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 ? $\endgroup$
    – Martin
    Commented May 19, 2017 at 17:08
  • $\begingroup$ @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. $\endgroup$
    – Haitao Du
    Commented May 19, 2017 at 17:13
  • $\begingroup$ 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? $\endgroup$
    – Martin
    Commented May 19, 2017 at 17:18
  • $\begingroup$ @Martin that seems to be off topic for CV. $\endgroup$
    – Haitao Du
    Commented May 19, 2017 at 17:21
  • $\begingroup$ Thanks for the heads up, this could be why i cannot find the answer to this problem anywhere. $\endgroup$
    – Martin
    Commented May 19, 2017 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.