O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

Step 1 loads the packages needed and step 2 reads the data.

Step 3 converts the outcome variable class to a factor. For nnet to perform classification, we need the outcome variable to be a factor. If you have predictor variables that are really categorical but have numeric values, convert them to factors so that nnet can treat them appropriately. As we have only numeric predictor variables, we need not do anything for the predictor variables.

Step 4 partitions the data. See Creating random data partitions in Chapter 2, What's In There? - Exploratory Data Analysis, for more details on this step.

Step 5 builds the neural network model. We pass the formula and dataset as the first two arguments:

  • The size argument specifies the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required