Prediction - a neural network for regression

I am trying to predict the median value of the owner-occupied houses, its processed example, which gives a good result. https://heuristically.wordpress.com/2011/11/17/using-neural-network-for-regression/

library(mlbench) data(BostonHousing) require(nnet) # scale inputs: divide by 50 to get 0-1 range nnet.fit <- nnet(medv/50 ~ ., data=BostonHousing, size=2) # multiply 50 to restore original scale nnet.predict <- predict(nnet.fit)*50 

nnet.predict [1] 1 23.70904 2 23.70904 3 23.70904 4 23.70904 5 23.70904 6 23.70904 7 23.70904 8 23.70904 9 23.70904 10 23.70904 11 23.70904 12 23.70904 13 23.70904 14 23.70904 15 23.70904

I get 23.70904 the same value for all forecasts for all 506 observations? Why is this so? What am I doing wrong?

My version of R is 3.1.2.

+5
source share
1 answer

This was associated with line = TRUE, which should be used for a continuous response variable. Since I used nnet for regression (and not for classification), I needed to set linout = T to tell nnet to use linear output

 nnet.fit <- nnet(medv/50 ~ ., data=BostonHousing, size=10, linout=TRUE, skip=TRUE, MaxNWts=10000, trace=FALSE, maxit=100) 

It worked well for me, hope it helps.

+6
source

All Articles