Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tree = 10000
- oob.err14 = numeric(10)
- for (mtry in 1:10) {
- fit14 = randomForest(lable ~ .-user_id -product_id, data = train_2, mtry = mtry, ntree = 10000)
- oob.err14[mtry] = fit14$err.rate[500]
- cat('We are performing iteration', mtry, '\n')
- }
- plot(1:10, oob.err14[1:10], pch = 16, type = 'b',
- xlab = 'Variance Cosidered at Each Split',
- ylab = 'OOB Mean Squared Error',
- main = '4_Random Forest OOB Error Rates\nby # of Variables')
- # variance important:
- varImpPlot(fit14)
- which(oob.err14 == min(oob.err14))
- oob.err14[10]
- ##### best model ######
- # mtry = 3
- fitt0 <- randomForest(lable ~ .-user_id -product_id, data = train_2, mtry = 3, ntree = 10000)
- fitt0
- varImpPlot(fitt0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement