Random Forest Classifier - KFold CV Tunes Very Deep Trees --> Overfitting?












1












$begingroup$


I'm tuning a random forest in python and am wondering if/why my model is overfit. The dataset is described below:




  • 1700 Positive Cases / 54000 total cases ~ 3.2% (unbalanced)

  • 50 Numerical Features,~450 label/hot encoded features (post data
    reduction)

  • 10Fold CV using 85% of data, with 15% hold out for final test

  • Classification Metrics = AUC or F1 (as data is imbalanced)


The results I get tend to suggest using very deep trees i.e depth 18 with no restriction on number of samples per split = 2(default). In this case, Train AUC was 99.9% , Max Test AUC was 84%. My scores are also almost monotonically increasing in max depth of trees. Given the results and how deep the trees are - I suspect the model is overfit? If this is the case then why would I not observe some sort of out of sample reduction in AUC as depth and min_samples_split typically constrain the random forest? Or have I overlooked anything in tuning?



My ranges in CV Grid Search are more or less:




  • n_estimates : range(100,1000,by=100)

  • max_features : {sqrt(p),0.3,0.4,0.5}

  • max_depth : range(2,20,by=1)

  • min_samples_split : range(2,50,by=1)

  • class_weights : {balanced,None}


Thanks










share|improve this question









$endgroup$




bumped to the homepage by Community 23 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    1












    $begingroup$


    I'm tuning a random forest in python and am wondering if/why my model is overfit. The dataset is described below:




    • 1700 Positive Cases / 54000 total cases ~ 3.2% (unbalanced)

    • 50 Numerical Features,~450 label/hot encoded features (post data
      reduction)

    • 10Fold CV using 85% of data, with 15% hold out for final test

    • Classification Metrics = AUC or F1 (as data is imbalanced)


    The results I get tend to suggest using very deep trees i.e depth 18 with no restriction on number of samples per split = 2(default). In this case, Train AUC was 99.9% , Max Test AUC was 84%. My scores are also almost monotonically increasing in max depth of trees. Given the results and how deep the trees are - I suspect the model is overfit? If this is the case then why would I not observe some sort of out of sample reduction in AUC as depth and min_samples_split typically constrain the random forest? Or have I overlooked anything in tuning?



    My ranges in CV Grid Search are more or less:




    • n_estimates : range(100,1000,by=100)

    • max_features : {sqrt(p),0.3,0.4,0.5}

    • max_depth : range(2,20,by=1)

    • min_samples_split : range(2,50,by=1)

    • class_weights : {balanced,None}


    Thanks










    share|improve this question









    $endgroup$




    bumped to the homepage by Community 23 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1





      $begingroup$


      I'm tuning a random forest in python and am wondering if/why my model is overfit. The dataset is described below:




      • 1700 Positive Cases / 54000 total cases ~ 3.2% (unbalanced)

      • 50 Numerical Features,~450 label/hot encoded features (post data
        reduction)

      • 10Fold CV using 85% of data, with 15% hold out for final test

      • Classification Metrics = AUC or F1 (as data is imbalanced)


      The results I get tend to suggest using very deep trees i.e depth 18 with no restriction on number of samples per split = 2(default). In this case, Train AUC was 99.9% , Max Test AUC was 84%. My scores are also almost monotonically increasing in max depth of trees. Given the results and how deep the trees are - I suspect the model is overfit? If this is the case then why would I not observe some sort of out of sample reduction in AUC as depth and min_samples_split typically constrain the random forest? Or have I overlooked anything in tuning?



      My ranges in CV Grid Search are more or less:




      • n_estimates : range(100,1000,by=100)

      • max_features : {sqrt(p),0.3,0.4,0.5}

      • max_depth : range(2,20,by=1)

      • min_samples_split : range(2,50,by=1)

      • class_weights : {balanced,None}


      Thanks










      share|improve this question









      $endgroup$




      I'm tuning a random forest in python and am wondering if/why my model is overfit. The dataset is described below:




      • 1700 Positive Cases / 54000 total cases ~ 3.2% (unbalanced)

      • 50 Numerical Features,~450 label/hot encoded features (post data
        reduction)

      • 10Fold CV using 85% of data, with 15% hold out for final test

      • Classification Metrics = AUC or F1 (as data is imbalanced)


      The results I get tend to suggest using very deep trees i.e depth 18 with no restriction on number of samples per split = 2(default). In this case, Train AUC was 99.9% , Max Test AUC was 84%. My scores are also almost monotonically increasing in max depth of trees. Given the results and how deep the trees are - I suspect the model is overfit? If this is the case then why would I not observe some sort of out of sample reduction in AUC as depth and min_samples_split typically constrain the random forest? Or have I overlooked anything in tuning?



      My ranges in CV Grid Search are more or less:




      • n_estimates : range(100,1000,by=100)

      • max_features : {sqrt(p),0.3,0.4,0.5}

      • max_depth : range(2,20,by=1)

      • min_samples_split : range(2,50,by=1)

      • class_weights : {balanced,None}


      Thanks







      machine-learning random-forest cross-validation unbalanced-classes






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 19 '18 at 22:32









      NahyyzNahyyz

      61




      61





      bumped to the homepage by Community 23 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 23 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0












          $begingroup$

          A drop in performance between train and test datasets is a sign of overfitting.



          Given the extremely unbalanced data, passing sample_weight argument to RandomForest().fit() to rebalance the classes should help.






          share|improve this answer











          $endgroup$













          • $begingroup$
            I'm using class_weights = "balanced" to take into account imbalances in the dataset and penalize the cost function. It seems the two are related per stackoverflow.com/questions/32492550/…
            $endgroup$
            – Nahyyz
            Jun 20 '18 at 3:15



















          -1












          $begingroup$

          Random Forests don't overfit, the more depth you add, the more accuracy and less performance you will get.






          share|improve this answer









          $endgroup$













          • $begingroup$
            Using deep trees is the problem, you have to increase the depth of your forest instead. Random Forests use very simple trees but thousands or 10th of thousands of them for that they can't overfit: Read the paper instead of downvoting.. projecteuclid.org/download/pdf_1/euclid.aos/1032181157
            $endgroup$
            – Eugen
            Jun 20 '18 at 1:48












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "557"
          };
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2fdatascience.stackexchange.com%2fquestions%2f33398%2frandom-forest-classifier-kfold-cv-tunes-very-deep-trees-overfitting%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0












          $begingroup$

          A drop in performance between train and test datasets is a sign of overfitting.



          Given the extremely unbalanced data, passing sample_weight argument to RandomForest().fit() to rebalance the classes should help.






          share|improve this answer











          $endgroup$













          • $begingroup$
            I'm using class_weights = "balanced" to take into account imbalances in the dataset and penalize the cost function. It seems the two are related per stackoverflow.com/questions/32492550/…
            $endgroup$
            – Nahyyz
            Jun 20 '18 at 3:15
















          0












          $begingroup$

          A drop in performance between train and test datasets is a sign of overfitting.



          Given the extremely unbalanced data, passing sample_weight argument to RandomForest().fit() to rebalance the classes should help.






          share|improve this answer











          $endgroup$













          • $begingroup$
            I'm using class_weights = "balanced" to take into account imbalances in the dataset and penalize the cost function. It seems the two are related per stackoverflow.com/questions/32492550/…
            $endgroup$
            – Nahyyz
            Jun 20 '18 at 3:15














          0












          0








          0





          $begingroup$

          A drop in performance between train and test datasets is a sign of overfitting.



          Given the extremely unbalanced data, passing sample_weight argument to RandomForest().fit() to rebalance the classes should help.






          share|improve this answer











          $endgroup$



          A drop in performance between train and test datasets is a sign of overfitting.



          Given the extremely unbalanced data, passing sample_weight argument to RandomForest().fit() to rebalance the classes should help.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 20 '18 at 14:12

























          answered Jun 20 '18 at 0:20









          Brian SpieringBrian Spiering

          4,2881129




          4,2881129












          • $begingroup$
            I'm using class_weights = "balanced" to take into account imbalances in the dataset and penalize the cost function. It seems the two are related per stackoverflow.com/questions/32492550/…
            $endgroup$
            – Nahyyz
            Jun 20 '18 at 3:15


















          • $begingroup$
            I'm using class_weights = "balanced" to take into account imbalances in the dataset and penalize the cost function. It seems the two are related per stackoverflow.com/questions/32492550/…
            $endgroup$
            – Nahyyz
            Jun 20 '18 at 3:15
















          $begingroup$
          I'm using class_weights = "balanced" to take into account imbalances in the dataset and penalize the cost function. It seems the two are related per stackoverflow.com/questions/32492550/…
          $endgroup$
          – Nahyyz
          Jun 20 '18 at 3:15




          $begingroup$
          I'm using class_weights = "balanced" to take into account imbalances in the dataset and penalize the cost function. It seems the two are related per stackoverflow.com/questions/32492550/…
          $endgroup$
          – Nahyyz
          Jun 20 '18 at 3:15











          -1












          $begingroup$

          Random Forests don't overfit, the more depth you add, the more accuracy and less performance you will get.






          share|improve this answer









          $endgroup$













          • $begingroup$
            Using deep trees is the problem, you have to increase the depth of your forest instead. Random Forests use very simple trees but thousands or 10th of thousands of them for that they can't overfit: Read the paper instead of downvoting.. projecteuclid.org/download/pdf_1/euclid.aos/1032181157
            $endgroup$
            – Eugen
            Jun 20 '18 at 1:48
















          -1












          $begingroup$

          Random Forests don't overfit, the more depth you add, the more accuracy and less performance you will get.






          share|improve this answer









          $endgroup$













          • $begingroup$
            Using deep trees is the problem, you have to increase the depth of your forest instead. Random Forests use very simple trees but thousands or 10th of thousands of them for that they can't overfit: Read the paper instead of downvoting.. projecteuclid.org/download/pdf_1/euclid.aos/1032181157
            $endgroup$
            – Eugen
            Jun 20 '18 at 1:48














          -1












          -1








          -1





          $begingroup$

          Random Forests don't overfit, the more depth you add, the more accuracy and less performance you will get.






          share|improve this answer









          $endgroup$



          Random Forests don't overfit, the more depth you add, the more accuracy and less performance you will get.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 20 '18 at 0:03









          EugenEugen

          795




          795












          • $begingroup$
            Using deep trees is the problem, you have to increase the depth of your forest instead. Random Forests use very simple trees but thousands or 10th of thousands of them for that they can't overfit: Read the paper instead of downvoting.. projecteuclid.org/download/pdf_1/euclid.aos/1032181157
            $endgroup$
            – Eugen
            Jun 20 '18 at 1:48


















          • $begingroup$
            Using deep trees is the problem, you have to increase the depth of your forest instead. Random Forests use very simple trees but thousands or 10th of thousands of them for that they can't overfit: Read the paper instead of downvoting.. projecteuclid.org/download/pdf_1/euclid.aos/1032181157
            $endgroup$
            – Eugen
            Jun 20 '18 at 1:48
















          $begingroup$
          Using deep trees is the problem, you have to increase the depth of your forest instead. Random Forests use very simple trees but thousands or 10th of thousands of them for that they can't overfit: Read the paper instead of downvoting.. projecteuclid.org/download/pdf_1/euclid.aos/1032181157
          $endgroup$
          – Eugen
          Jun 20 '18 at 1:48




          $begingroup$
          Using deep trees is the problem, you have to increase the depth of your forest instead. Random Forests use very simple trees but thousands or 10th of thousands of them for that they can't overfit: Read the paper instead of downvoting.. projecteuclid.org/download/pdf_1/euclid.aos/1032181157
          $endgroup$
          – Eugen
          Jun 20 '18 at 1:48


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Data Science Stack Exchange!


          • 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.


          Use MathJax to format equations. MathJax reference.


          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%2fdatascience.stackexchange.com%2fquestions%2f33398%2frandom-forest-classifier-kfold-cv-tunes-very-deep-trees-overfitting%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

          Callistus I

          Tabula Rosettana

          How to label and detect the document text images