http://wenku.baidu.com/view/a505b8a0011ca300a7c39005.html
http://mirror.bjtu.edu.cn/cran/web/packages/nnetpredint/nnetpredint.pdf
- # neuralnet 训练神经网络模型,结构为 c(13,5,3,1)
- library(MASS)
- data <- Boston
- maxs <- apply(data, 2, max)
- mins <- apply(data, 2, min)
- scaled <- as.data.frame(scale(data, center = mins, scale = maxs - mins)) # normalization
- index <- sample(1:nrow(data),round(0.75*nrow(data)))
- train_ <- scaled[index,]
- test_ <- scaled[-index,]
- library(neuralnet) # Training
- n <- names(train_)
- f <- as.formula(paste("medv ~", paste(n[!n %in% "medv"], collapse = " + ")))
- nn <- neuralnet(f,data = train_,hidden = c(5,3),linear.output = FALSE)
- plot(nn)
- library(nnetpredint) # Getting prediction confidence interval
- x <- train_[,-14]
- y <- train_[,14]
- newData <- test_[,-14]
- # S3 generic method: Object of nn
- yPredInt <- nnetPredInt(nn, x, y, newData)
- print(yPredInt[1:20,])


雷达卡


京公网安备 11010802022788号







