0

I am very new to R language. Here is my code ..

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))

here when I check prediction[1] or any test data, it always give me same response.

Jyoti
  • 1
  • 2
  • 2
    Please provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data so we can run your code to see what's going on. – MrFlick Apr 15 '17 at 18:25
  • And please mention the R libraries you are using. – tagoma Apr 15 '17 at 18:54
  • install.packages("MASS") library(MASS) library(neuralnet) set.seed(123) #DataFrame <- read.csv("E:/dataset/FinalDataset/testdata.csv") DataFrame <- read.csv("D:/DataSet14_04/data_ahm_bhopal_jodhpur.csv") Here is the data available : https://www.dropbox.com/s/sifcb4fvqemxhxo/data_ahm_bhopal_jodhpur.csv?dl=0 – Jyoti Apr 15 '17 at 18:56
  • It would be much more helpful if you used `dput` to generate R code of your data, and you placed it in the post, formatted. – sebastianmm May 06 '17 at 19:23

0 Answers0