How does mtry affect the speed of randomForest when tuning with cross validation in R?










1















I tried to tune my randomForest model with codes below:



trControl=trainControl(method="cv",number=10)

tuneGrid = expand.grid(mtry=1:5)


And then I used



train(model,data=data,method="rf",ntree=500,trControl=trControl,tuneGrid=tuneGrid)


to find for the best mtry



It took about 3 hours to finish



However, when I changed expand.grid(mtry=1:5) to expand.grid(mtry=1:8), the codes did not finish in more than 9 hours. I want to ask how does the parameter mtry affect the speed of tuning randomForest. Or in other words, what exactly does the parameter mtry do in the tuning process?










share|improve this question



















  • 4





    @12b345b6b78 No, ntree is the number of trees built. mtry is the number of features tried out at each split to find the most significant. Fewer options to test will make the model run faster, but usually you care more about a metric like accuracy or RMSE more than run time, so mtry is optimized accordingly.

    – alistaire
    Nov 13 '18 at 4:30












  • You might want to use method = "ranger". This will use the randomForest from the ranger package and will speed up your code significantly.

    – phiver
    Nov 13 '18 at 12:18











  • @phiver, Hi, thanks for your advice. I tried to use method = "ranger' but it returns error that says "something is wrong, all the rmse are missing". But the same error did not occur when using method = "rf"

    – Sanguis
    Nov 13 '18 at 15:07















1















I tried to tune my randomForest model with codes below:



trControl=trainControl(method="cv",number=10)

tuneGrid = expand.grid(mtry=1:5)


And then I used



train(model,data=data,method="rf",ntree=500,trControl=trControl,tuneGrid=tuneGrid)


to find for the best mtry



It took about 3 hours to finish



However, when I changed expand.grid(mtry=1:5) to expand.grid(mtry=1:8), the codes did not finish in more than 9 hours. I want to ask how does the parameter mtry affect the speed of tuning randomForest. Or in other words, what exactly does the parameter mtry do in the tuning process?










share|improve this question



















  • 4





    @12b345b6b78 No, ntree is the number of trees built. mtry is the number of features tried out at each split to find the most significant. Fewer options to test will make the model run faster, but usually you care more about a metric like accuracy or RMSE more than run time, so mtry is optimized accordingly.

    – alistaire
    Nov 13 '18 at 4:30












  • You might want to use method = "ranger". This will use the randomForest from the ranger package and will speed up your code significantly.

    – phiver
    Nov 13 '18 at 12:18











  • @phiver, Hi, thanks for your advice. I tried to use method = "ranger' but it returns error that says "something is wrong, all the rmse are missing". But the same error did not occur when using method = "rf"

    – Sanguis
    Nov 13 '18 at 15:07













1












1








1








I tried to tune my randomForest model with codes below:



trControl=trainControl(method="cv",number=10)

tuneGrid = expand.grid(mtry=1:5)


And then I used



train(model,data=data,method="rf",ntree=500,trControl=trControl,tuneGrid=tuneGrid)


to find for the best mtry



It took about 3 hours to finish



However, when I changed expand.grid(mtry=1:5) to expand.grid(mtry=1:8), the codes did not finish in more than 9 hours. I want to ask how does the parameter mtry affect the speed of tuning randomForest. Or in other words, what exactly does the parameter mtry do in the tuning process?










share|improve this question
















I tried to tune my randomForest model with codes below:



trControl=trainControl(method="cv",number=10)

tuneGrid = expand.grid(mtry=1:5)


And then I used



train(model,data=data,method="rf",ntree=500,trControl=trControl,tuneGrid=tuneGrid)


to find for the best mtry



It took about 3 hours to finish



However, when I changed expand.grid(mtry=1:5) to expand.grid(mtry=1:8), the codes did not finish in more than 9 hours. I want to ask how does the parameter mtry affect the speed of tuning randomForest. Or in other words, what exactly does the parameter mtry do in the tuning process?







r random-forest cross-validation r-caret






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 4:31









alistaire

31.7k43764




31.7k43764










asked Nov 13 '18 at 3:43









SanguisSanguis

113




113







  • 4





    @12b345b6b78 No, ntree is the number of trees built. mtry is the number of features tried out at each split to find the most significant. Fewer options to test will make the model run faster, but usually you care more about a metric like accuracy or RMSE more than run time, so mtry is optimized accordingly.

    – alistaire
    Nov 13 '18 at 4:30












  • You might want to use method = "ranger". This will use the randomForest from the ranger package and will speed up your code significantly.

    – phiver
    Nov 13 '18 at 12:18











  • @phiver, Hi, thanks for your advice. I tried to use method = "ranger' but it returns error that says "something is wrong, all the rmse are missing". But the same error did not occur when using method = "rf"

    – Sanguis
    Nov 13 '18 at 15:07












  • 4





    @12b345b6b78 No, ntree is the number of trees built. mtry is the number of features tried out at each split to find the most significant. Fewer options to test will make the model run faster, but usually you care more about a metric like accuracy or RMSE more than run time, so mtry is optimized accordingly.

    – alistaire
    Nov 13 '18 at 4:30












  • You might want to use method = "ranger". This will use the randomForest from the ranger package and will speed up your code significantly.

    – phiver
    Nov 13 '18 at 12:18











  • @phiver, Hi, thanks for your advice. I tried to use method = "ranger' but it returns error that says "something is wrong, all the rmse are missing". But the same error did not occur when using method = "rf"

    – Sanguis
    Nov 13 '18 at 15:07







4




4





@12b345b6b78 No, ntree is the number of trees built. mtry is the number of features tried out at each split to find the most significant. Fewer options to test will make the model run faster, but usually you care more about a metric like accuracy or RMSE more than run time, so mtry is optimized accordingly.

– alistaire
Nov 13 '18 at 4:30






@12b345b6b78 No, ntree is the number of trees built. mtry is the number of features tried out at each split to find the most significant. Fewer options to test will make the model run faster, but usually you care more about a metric like accuracy or RMSE more than run time, so mtry is optimized accordingly.

– alistaire
Nov 13 '18 at 4:30














You might want to use method = "ranger". This will use the randomForest from the ranger package and will speed up your code significantly.

– phiver
Nov 13 '18 at 12:18





You might want to use method = "ranger". This will use the randomForest from the ranger package and will speed up your code significantly.

– phiver
Nov 13 '18 at 12:18













@phiver, Hi, thanks for your advice. I tried to use method = "ranger' but it returns error that says "something is wrong, all the rmse are missing". But the same error did not occur when using method = "rf"

– Sanguis
Nov 13 '18 at 15:07





@phiver, Hi, thanks for your advice. I tried to use method = "ranger' but it returns error that says "something is wrong, all the rmse are missing". But the same error did not occur when using method = "rf"

– Sanguis
Nov 13 '18 at 15:07












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273470%2fhow-does-mtry-affect-the-speed-of-randomforest-when-tuning-with-cross-validation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273470%2fhow-does-mtry-affect-the-speed-of-randomforest-when-tuning-with-cross-validation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo