mercredi 26 septembre 2018

I wanted to apply random forest regression in R ..The error is Error in `[.default`(xj, i) : invalid subscript type 'list'

I am a civil student learning R for my data related to civil work.So my level of understanding is very basic.Please help out with the issue I am facing.

 library(randomForest)
model1<-randomForest(Manhours~.,data = numdata,subset=training_set,importance= TRUE,na.action = na.roughfix)
model1
plot(model1)

oob.err=double(5)
test.err=double(5)
for(mtry in 1:5) 
{
  rf=randomForest(Manhours~.,data = numedata,subset=training_set,ntree =500 
                  ,mtry = mtry,importance = TRUE,na.action = na.roughfix) 
  oob.err[mtry] = rf$mse[400] 

  prediction<-predict(rf,newdata = numdata[-training_set] ) 
  test.err[mtry]= with(numdata[-training_set], mean( (Manhours- pred)^2)) 
  cat(mtry," ")   

}




Aucun commentaire:

Enregistrer un commentaire