Skip to main content
added 274 characters in body
Source Link
Seanosapien
  • 179
  • 2
  • 10

If you already knowhave an idea about how many trees you want to use (Breiman recommends at least 1000) and have used randomForest::tuneRF to get an optimal mtry value (let's use 6 as an example), then:

ctrl <- trainControl(method = "none")

set.seed(2)
rforest <- train(response ~ ., data = data_set,
               method = "rf",
               ntree = 1000,
               trControl = ctrl,
               tuneGrid = data.frame(mtry = 6))

Eduardo has answered your question above but I wanted to additionally demonstrate how you can tune the value for the number of random variables used for partitioning. When tuning a random forest, this parameter has more importance than ntree as long as ntree is sufficiently large.

If you already know how many trees you want to use (Breiman recommends at least 1000) and have used randomForest::tuneRF to get an optimal mtry value (let's use 6), then:

ctrl <- trainControl(method = "none")

set.seed(2)
rforest <- train(response ~ ., data = data_set,
               method = "rf",
               ntree = 1000,
               trControl = ctrl,
               tuneGrid = data.frame(mtry = 6))

If you already have an idea about how many trees you want to use (Breiman recommends at least 1000) and have used randomForest::tuneRF to get an optimal mtry value (let's use 6 as an example), then:

ctrl <- trainControl(method = "none")

set.seed(2)
rforest <- train(response ~ ., data = data_set,
               method = "rf",
               ntree = 1000,
               trControl = ctrl,
               tuneGrid = data.frame(mtry = 6))

Eduardo has answered your question above but I wanted to additionally demonstrate how you can tune the value for the number of random variables used for partitioning. When tuning a random forest, this parameter has more importance than ntree as long as ntree is sufficiently large.

If you already know how many trees you want to use (Breiman recommends at least 1000) and have used tuneRF()randomForest::tuneRF to get an optimal mtrymtry value (let's use 6), then:

ctrl <- trainControl(method = "none")

set.seed(2)
rforest <- train(response ~ ., data = data_set,
               method = "rf",
               ntree = 1000,
               trControl = ctrl,
               tuneGrid = data.frame(mtry = 6))

If you already know how many trees you want to use (Breiman recommends at least 1000) and have used tuneRF() to get an optimal mtry value (let's use 6), then:

ctrl <- trainControl(method = "none")

set.seed(2)
rforest <- train(response ~ ., data = data_set,
               method = "rf",
               ntree = 1000,
               trControl = ctrl,
               tuneGrid = data.frame(mtry = 6))

If you already know how many trees you want to use (Breiman recommends at least 1000) and have used randomForest::tuneRF to get an optimal mtry value (let's use 6), then:

ctrl <- trainControl(method = "none")

set.seed(2)
rforest <- train(response ~ ., data = data_set,
               method = "rf",
               ntree = 1000,
               trControl = ctrl,
               tuneGrid = data.frame(mtry = 6))
Source Link
Seanosapien
  • 179
  • 2
  • 10

If you already know how many trees you want to use (Breiman recommends at least 1000) and have used tuneRF() to get an optimal mtry value (let's use 6), then:

ctrl <- trainControl(method = "none")

set.seed(2)
rforest <- train(response ~ ., data = data_set,
               method = "rf",
               ntree = 1000,
               trControl = ctrl,
               tuneGrid = data.frame(mtry = 6))