Step 1 loads the necessary packages--nnet for neural network modeling and caret for data partitioning. We also load devtools because we will be sourcing code using a web URL for printing the network.
Step 2 reads the file.
Step 3 partitions the data. Refer to the Creating random data partitions recipe from Chapter 2, What's in There? - Exploratory Data Analysis for more details. We have set the random seed to enable you to match your results with those that we have displayed.
Step 4 builds the neural net model using the nnet function of the nnet package:
> fit <- nnet(MEDV/50 ~ ., data=bh[t.idx,], size=6, decay = 0.1, maxit = 1000, linout = TRUE)
We divide our response variable by 50 to scale it to the range [0, 1]. We pass ...