预测 - 回归的神经网络

时间:2015-04-26 22:10:20

标签: r neural-network regression prediction predict

我试图预测自住房屋的中位数值,这是一个效果良好的例子。 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

对于所有506次观察的所有预测,我得到23.70904相同的值?为什么会这样?我做错了什么?

我的R版本是3.1.2。

1 个答案:

答案 0 :(得分:7)

这是由于linout = TRUE需要用于连续响应变量。由于我使用nnet进行回归(而不是分类)问题,我需要设置linout = T来告诉nnet使用线性输出“

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

这对我有用,希望有所帮助。

相关问题