我对R语言很新。这是我的代码..
apply(DataFrame,2,range)
maxValue <- apply(DataFrame,2,max)
minValue <- apply(DataFrame,2,min)
#not used ...
DataFrame<- as.data.frame(scale(DataFrame, center = minValue,scale = maxValue-minValue))
ind<- sample(1:nrow(DataFrame),2000)
trainDF <- DataFrame[ind,]
testDF <- DataFrame[-ind,]
head(trainDF)
allVars <-colnames(DataFrame)
predictorVars <- allVars[!allVars%in%"TEMP"]
predictorVars <- paste(predictorVars,collapse = "+")
form=as.formula(paste("TEMP~",predictorVars,collapse = "+"))
#form= (paste("TEMP~DEWP+SLP+STP+VISIB+WDSP+MAX+MIN"))
neuralModel <- neuralnet(formula= form, hidden = c(4,2),linear.output = FALSE ,data=trainDF)
plot(neuralModel)
head(testDF)
prediction <- compute(neuralModel, testDF[,1:11])
str(prediction)
prediction <- prediction$net.result*(max(testDF$TEMP)-min(testDF$TEMP))+min(testDF$TEMP)
actualValues <- ((testDF$TEMP)*(max(testDF$TEMP)-min(testDF$TEMP))+min(testDF$TEMP))
这里当我检查预测[1]或任何测试数据时,它总是给我相同的响应。