Guest User

Untitled

a guest
Oct 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. set.seed(2)
  2. ind=sample(nrow(Boston),trunc(0.7*nrow(Boston)))
  3. train=Boston[ind,]
  4. test=Boston[-ind,]
  5.  
  6. # Fit lm model using 5 x 5-fold CV: model
  7. model <- train(
  8. medv ~ ., train,
  9. method = "ranger",
  10. trControl = trainControl(
  11. method = "repeatedcv", number = 5,
  12. repeats = 5, verboseIter = F
  13. )
  14. )
  15.  
  16. Random Forest
  17.  
  18. 354 samples
  19. 13 predictor
  20.  
  21. No pre-processing
  22. Resampling: Cross-Validated (5 fold, repeated 5 times)
  23. Summary of sample sizes: 282, 282, 285, 283, 284, 283, ...
  24. Resampling results across tuning parameters:
  25.  
  26. mtry splitrule RMSE Rsquared MAE
  27. 2 variance 4.172443 0.8113023 2.702026
  28. 2 extratrees 4.574969 0.7819608 2.946490
  29. 7 variance 3.744418 0.8324785 2.475156
  30. 7 extratrees 3.812538 0.8342013 2.478945
  31. 13 variance 3.821406 0.8214275 2.517686
  32. 13 extratrees 3.795269 0.8282988 2.465104
  33.  
  34. Tuning parameter 'min.node.size' was held constant at a value of 5
  35. RMSE was used to select the optimal model using the smallest value.
  36. The final values used for the model were mtry = 7, splitrule = variance and min.node.size = 5.
  37.  
  38. sqrt(mean((predict(model)-train$medv)^2)) # 1.487133
  39. sqrt(mean((predict(model,newdata=test)-test$medv)^2)) # 2.648461
Add Comment
Please, Sign In to add comment