Random Forest Classifier - KFold CV Tunes Very Deep Trees --> Overfitting? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election ResultsHow to avoid overfitting in random forest?Minimum number of trees for Random Forest classifierPossible Reason for low Test accuracy and high AUCXGBoost Classification Probabilities higher than RF or SVM?Threshold Value for Random Forest ClassifierRandom Forest Classifier ProbabilitiesRandom Forest - Explanation ParameterEvaluating the performance of a random forest classifierUsing deep learning or random forestvery low recall value using random forest

An adverb for when you're not exaggerating

Do I really need to have a message in a novel to appeal to readers?

Antipodal Land Area Calculation

Why weren't discrete x86 CPUs ever used in game hardware?

Why can't I install Tomboy in Ubuntu Mate 19.04?

Should a wizard buy fine inks every time he want to copy spells into his spellbook?

What is the home of the drow in Flanaess?

What does it mean that physics no longer uses mechanical models to describe phenomena?

A term for a woman complaining about things/begging in a cute/childish way

Is CEO the "profession" with the most psychopaths?

Did any compiler fully use 80-bit floating point?

How to pronounce 伝統色

Significance of Cersei's obsession with elephants?

What is "gratricide"?

Why are my pictures showing a dark band on one edge?

What is the meaning of 'breadth' in breadth first search?

Flash light on something

Trademark violation for app?

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

What would you call this weird metallic apparatus that allows you to lift people?

How many morphisms from 1 to 1+1 can there be?

How can I prevent/balance waiting and turtling as a response to cooldown mechanics

Where is the Data Import Wizard Error Log

Can a Beast Master ranger change beast companions?



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



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election ResultsHow to avoid overfitting in random forest?Minimum number of trees for Random Forest classifierPossible Reason for low Test accuracy and high AUCXGBoost Classification Probabilities higher than RF or SVM?Threshold Value for Random Forest ClassifierRandom Forest Classifier ProbabilitiesRandom Forest - Explanation ParameterEvaluating the performance of a random forest classifierUsing deep learning or random forestvery low recall value using random forest










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 27 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 27 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 27 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 27 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

          Ружовы пелікан Змест Знешні выгляд | Пашырэнне | Асаблівасці біялогіі | Літаратура | НавігацыяДагледжаная версіяправерана1 зменаДагледжаная версіяправерана1 змена/ 22697590 Сістэматыкана ВіківідахВыявына Вікісховішчы174693363011049382

          ValueError: Error when checking input: expected conv2d_13_input to have shape (3, 150, 150) but got array with shape (150, 150, 3)2019 Community Moderator ElectionError when checking : expected dense_1_input to have shape (None, 5) but got array with shape (200, 1)Error 'Expected 2D array, got 1D array instead:'ValueError: Error when checking input: expected lstm_41_input to have 3 dimensions, but got array with shape (40000,100)ValueError: Error when checking target: expected dense_1 to have shape (7,) but got array with shape (1,)ValueError: Error when checking target: expected dense_2 to have shape (1,) but got array with shape (0,)Keras exception: ValueError: Error when checking input: expected conv2d_1_input to have shape (150, 150, 3) but got array with shape (256, 256, 3)Steps taking too long to completewhen checking input: expected dense_1_input to have shape (13328,) but got array with shape (317,)ValueError: Error when checking target: expected dense_3 to have shape (None, 1) but got array with shape (7715, 40000)Keras exception: Error when checking input: expected dense_input to have shape (2,) but got array with shape (1,)

          Illegal assignment from SObject to ContactFetching String, Id from Map - Illegal Assignment Id to Field / ObjectError: Compile Error: Illegal assignment from String to BooleanError: List has no rows for assignment to SObjectError on Test Class - System.QueryException: List has no rows for assignment to SObjectRemote action problemDML requires SObject or SObject list type error“Illegal assignment from List to List”Test Class Fail: Batch Class: System.QueryException: List has no rows for assignment to SObjectMapping to a user'List has no rows for assignment to SObject' Mystery