Overfitting - how to detect it and reduce it?2019 Community Moderator ElectionNested cross-validation and selecting the best regression model - is this the right SKLearn process?How to represent ROC curve when using Cross-ValidationCan overfitting occur even with validation loss still dropping?why k-fold cross validation (CV) overfits? Or why discrepancy occurs between CV and test set?How to know the model has started overfitting?Overfitting XGBoostSignificant overfitting with CVIs my model overfitting when I add new features?A few questions to understand a random forest blog

Expand and Contract

Forgetting the musical notes while performing in concert

How do I deal with an unproductive colleague in a small company?

Why didn't Boeing produce its own regional jet?

Plagiarism or not?

What exploit Are these user agents trying to use?

CAST throwing error when run in stored procedure but not when run as raw query

What's the in-universe reasoning behind sorcerers needing material components?

Little known, relatively unlikely, but scientifically plausible, apocalyptic (or near apocalyptic) events

Is it logically or scientifically possible to artificially send energy to the body?

What are some good books on Machine Learning and AI like Krugman, Wells and Graddy's "Essentials of Economics"

Bullying boss launched a smear campaign and made me unemployable

Could the museum Saturn V's be refitted for one more flight?

How to prevent "they're falling in love" trope

How to show a landlord what we have in savings?

Is there an expression that means doing something right before you will need it rather than doing it in case you might need it?

Size of subfigure fitting its content (tikzpicture)

Personal Teleportation: From Rags to Riches

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

Im going to France and my passport expires June 19th

Avoiding direct proof while writing proof by induction

Zip/Tar file compressed to larger size?

Extract rows of a table, that include less than x NULLs

How to Recreate this in LaTeX? (Unsure What the Notation is Called)



Overfitting - how to detect it and reduce it?



2019 Community Moderator ElectionNested cross-validation and selecting the best regression model - is this the right SKLearn process?How to represent ROC curve when using Cross-ValidationCan overfitting occur even with validation loss still dropping?why k-fold cross validation (CV) overfits? Or why discrepancy occurs between CV and test set?How to know the model has started overfitting?Overfitting XGBoostSignificant overfitting with CVIs my model overfitting when I add new features?A few questions to understand a random forest blog










0












$begingroup$


I have a side project where I am doing credit scoring using R (sample size around 16k for train data and 4k for test data, and also another two 20k data batches for out-of-time validation) with unbalanced classes (3.5% of BAD type of clients).



I'm trying to make various models to have enough of them to make ensembles, but for this purpose, let's focus on one of them, particularly XGBoost.



I was reading a lot on how to tackle overfitting, but I haven't found any good source on how to do it in practice, step-by-step. As for now, my two best models have:



  1. 0.8 AUC on training data, around 0.799 AUC on holdout set and around 0.7355 and 0.7195 AUC on out-of-time batches.


  2. 0.764 AUC on training, 0.7785 AUC on the holdout test set and 0,7285 AUC on both out-of-time batches.


I am worried about is that drop on out-of-time batches, since I think that 0.05-0.08 drop is huge and it might be a sign that models that I did, really are overfitting and don't generalize well. To clarify, while I was tweaking models, I didn't know about those out-of-time scores.



Could anyone share the experience what is best practice to detect overfitting? And does those two models overfit, or I am just panicking, and this drop in performance is normal?



My current pipeline in general looks like this:



  1. Data cleanup


  2. Feature importance using xgboost package to take best 300 features from all 2400 available.


  3. Removing highly-correlated features (0.75 cutoff) - 123 features left


  4. Train/test split - 0.8 vs 0.2 plus two out-of-time batches


  5. Model selection using nested CV(5-fold CV in outer) with hyperparameter tuning in inner loop(5-fold CV in inner) - all done in MLR package.


  6. From 5 models I get from nested CV, I'm picking the best performing one (that has the closest AUC in both train and holdout test set)


And then when I was happy with the model I performed a test on out-of-time models.



How I could improve my pipeline, in a way that I could detect overfitting? Is there any list of steps that would roughly cover what it could be done to reduce it?



Also, in highly unbalanced case, choosing a good validation set means that I only need to take care of the proper distribution of the target variable? Should I take care of something else as well?










share|improve this question











$endgroup$




bumped to the homepage by Community 10 mins ago


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



















    0












    $begingroup$


    I have a side project where I am doing credit scoring using R (sample size around 16k for train data and 4k for test data, and also another two 20k data batches for out-of-time validation) with unbalanced classes (3.5% of BAD type of clients).



    I'm trying to make various models to have enough of them to make ensembles, but for this purpose, let's focus on one of them, particularly XGBoost.



    I was reading a lot on how to tackle overfitting, but I haven't found any good source on how to do it in practice, step-by-step. As for now, my two best models have:



    1. 0.8 AUC on training data, around 0.799 AUC on holdout set and around 0.7355 and 0.7195 AUC on out-of-time batches.


    2. 0.764 AUC on training, 0.7785 AUC on the holdout test set and 0,7285 AUC on both out-of-time batches.


    I am worried about is that drop on out-of-time batches, since I think that 0.05-0.08 drop is huge and it might be a sign that models that I did, really are overfitting and don't generalize well. To clarify, while I was tweaking models, I didn't know about those out-of-time scores.



    Could anyone share the experience what is best practice to detect overfitting? And does those two models overfit, or I am just panicking, and this drop in performance is normal?



    My current pipeline in general looks like this:



    1. Data cleanup


    2. Feature importance using xgboost package to take best 300 features from all 2400 available.


    3. Removing highly-correlated features (0.75 cutoff) - 123 features left


    4. Train/test split - 0.8 vs 0.2 plus two out-of-time batches


    5. Model selection using nested CV(5-fold CV in outer) with hyperparameter tuning in inner loop(5-fold CV in inner) - all done in MLR package.


    6. From 5 models I get from nested CV, I'm picking the best performing one (that has the closest AUC in both train and holdout test set)


    And then when I was happy with the model I performed a test on out-of-time models.



    How I could improve my pipeline, in a way that I could detect overfitting? Is there any list of steps that would roughly cover what it could be done to reduce it?



    Also, in highly unbalanced case, choosing a good validation set means that I only need to take care of the proper distribution of the target variable? Should I take care of something else as well?










    share|improve this question











    $endgroup$




    bumped to the homepage by Community 10 mins ago


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

















      0












      0








      0





      $begingroup$


      I have a side project where I am doing credit scoring using R (sample size around 16k for train data and 4k for test data, and also another two 20k data batches for out-of-time validation) with unbalanced classes (3.5% of BAD type of clients).



      I'm trying to make various models to have enough of them to make ensembles, but for this purpose, let's focus on one of them, particularly XGBoost.



      I was reading a lot on how to tackle overfitting, but I haven't found any good source on how to do it in practice, step-by-step. As for now, my two best models have:



      1. 0.8 AUC on training data, around 0.799 AUC on holdout set and around 0.7355 and 0.7195 AUC on out-of-time batches.


      2. 0.764 AUC on training, 0.7785 AUC on the holdout test set and 0,7285 AUC on both out-of-time batches.


      I am worried about is that drop on out-of-time batches, since I think that 0.05-0.08 drop is huge and it might be a sign that models that I did, really are overfitting and don't generalize well. To clarify, while I was tweaking models, I didn't know about those out-of-time scores.



      Could anyone share the experience what is best practice to detect overfitting? And does those two models overfit, or I am just panicking, and this drop in performance is normal?



      My current pipeline in general looks like this:



      1. Data cleanup


      2. Feature importance using xgboost package to take best 300 features from all 2400 available.


      3. Removing highly-correlated features (0.75 cutoff) - 123 features left


      4. Train/test split - 0.8 vs 0.2 plus two out-of-time batches


      5. Model selection using nested CV(5-fold CV in outer) with hyperparameter tuning in inner loop(5-fold CV in inner) - all done in MLR package.


      6. From 5 models I get from nested CV, I'm picking the best performing one (that has the closest AUC in both train and holdout test set)


      And then when I was happy with the model I performed a test on out-of-time models.



      How I could improve my pipeline, in a way that I could detect overfitting? Is there any list of steps that would roughly cover what it could be done to reduce it?



      Also, in highly unbalanced case, choosing a good validation set means that I only need to take care of the proper distribution of the target variable? Should I take care of something else as well?










      share|improve this question











      $endgroup$




      I have a side project where I am doing credit scoring using R (sample size around 16k for train data and 4k for test data, and also another two 20k data batches for out-of-time validation) with unbalanced classes (3.5% of BAD type of clients).



      I'm trying to make various models to have enough of them to make ensembles, but for this purpose, let's focus on one of them, particularly XGBoost.



      I was reading a lot on how to tackle overfitting, but I haven't found any good source on how to do it in practice, step-by-step. As for now, my two best models have:



      1. 0.8 AUC on training data, around 0.799 AUC on holdout set and around 0.7355 and 0.7195 AUC on out-of-time batches.


      2. 0.764 AUC on training, 0.7785 AUC on the holdout test set and 0,7285 AUC on both out-of-time batches.


      I am worried about is that drop on out-of-time batches, since I think that 0.05-0.08 drop is huge and it might be a sign that models that I did, really are overfitting and don't generalize well. To clarify, while I was tweaking models, I didn't know about those out-of-time scores.



      Could anyone share the experience what is best practice to detect overfitting? And does those two models overfit, or I am just panicking, and this drop in performance is normal?



      My current pipeline in general looks like this:



      1. Data cleanup


      2. Feature importance using xgboost package to take best 300 features from all 2400 available.


      3. Removing highly-correlated features (0.75 cutoff) - 123 features left


      4. Train/test split - 0.8 vs 0.2 plus two out-of-time batches


      5. Model selection using nested CV(5-fold CV in outer) with hyperparameter tuning in inner loop(5-fold CV in inner) - all done in MLR package.


      6. From 5 models I get from nested CV, I'm picking the best performing one (that has the closest AUC in both train and holdout test set)


      And then when I was happy with the model I performed a test on out-of-time models.



      How I could improve my pipeline, in a way that I could detect overfitting? Is there any list of steps that would roughly cover what it could be done to reduce it?



      Also, in highly unbalanced case, choosing a good validation set means that I only need to take care of the proper distribution of the target variable? Should I take care of something else as well?







      r cross-validation unbalanced-classes overfitting






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 5 at 3:08









      Kiritee Gak

      1,3591521




      1,3591521










      asked Mar 4 at 15:09









      AvistianAvistian

      1




      1





      bumped to the homepage by Community 10 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 10 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 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          When choosing the validation set and the test set, it is important that it reflects the actual "production environment" of your problem. Since you have "out of time" validation sets, I assume you have some time structure in your data that you need to address when making predictions. If you are developing your model, not taking this time aspect into consideration, you are likely to get issues when this model is put into a realistic environment because the models are fit to an unrealistic scenario where time does not matter.



          From the scores you show here, the train and test scores are very similar, while it drops off in the "out of time"-set. This might be an indication that you are not putting enough emphasis on the time dimension while developing your model.



          Another point: There is also fully possible to overfit to your validation set, when as in your case, you have a lot of variables. Since some combination of these variables might randomly fit your train and validation set well, it might not be the case for your test set. This effect is also magnified by my earlier point, where the data generating process is not really stationary across time.



          Here is a nice article about how to choose a good validation set:
          https://www.fast.ai/2017/11/13/validation-sets/






          share|improve this answer











          $endgroup$













            Your Answer





            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            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%2f46646%2foverfitting-how-to-detect-it-and-reduce-it%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0












            $begingroup$

            When choosing the validation set and the test set, it is important that it reflects the actual "production environment" of your problem. Since you have "out of time" validation sets, I assume you have some time structure in your data that you need to address when making predictions. If you are developing your model, not taking this time aspect into consideration, you are likely to get issues when this model is put into a realistic environment because the models are fit to an unrealistic scenario where time does not matter.



            From the scores you show here, the train and test scores are very similar, while it drops off in the "out of time"-set. This might be an indication that you are not putting enough emphasis on the time dimension while developing your model.



            Another point: There is also fully possible to overfit to your validation set, when as in your case, you have a lot of variables. Since some combination of these variables might randomly fit your train and validation set well, it might not be the case for your test set. This effect is also magnified by my earlier point, where the data generating process is not really stationary across time.



            Here is a nice article about how to choose a good validation set:
            https://www.fast.ai/2017/11/13/validation-sets/






            share|improve this answer











            $endgroup$

















              0












              $begingroup$

              When choosing the validation set and the test set, it is important that it reflects the actual "production environment" of your problem. Since you have "out of time" validation sets, I assume you have some time structure in your data that you need to address when making predictions. If you are developing your model, not taking this time aspect into consideration, you are likely to get issues when this model is put into a realistic environment because the models are fit to an unrealistic scenario where time does not matter.



              From the scores you show here, the train and test scores are very similar, while it drops off in the "out of time"-set. This might be an indication that you are not putting enough emphasis on the time dimension while developing your model.



              Another point: There is also fully possible to overfit to your validation set, when as in your case, you have a lot of variables. Since some combination of these variables might randomly fit your train and validation set well, it might not be the case for your test set. This effect is also magnified by my earlier point, where the data generating process is not really stationary across time.



              Here is a nice article about how to choose a good validation set:
              https://www.fast.ai/2017/11/13/validation-sets/






              share|improve this answer











              $endgroup$















                0












                0








                0





                $begingroup$

                When choosing the validation set and the test set, it is important that it reflects the actual "production environment" of your problem. Since you have "out of time" validation sets, I assume you have some time structure in your data that you need to address when making predictions. If you are developing your model, not taking this time aspect into consideration, you are likely to get issues when this model is put into a realistic environment because the models are fit to an unrealistic scenario where time does not matter.



                From the scores you show here, the train and test scores are very similar, while it drops off in the "out of time"-set. This might be an indication that you are not putting enough emphasis on the time dimension while developing your model.



                Another point: There is also fully possible to overfit to your validation set, when as in your case, you have a lot of variables. Since some combination of these variables might randomly fit your train and validation set well, it might not be the case for your test set. This effect is also magnified by my earlier point, where the data generating process is not really stationary across time.



                Here is a nice article about how to choose a good validation set:
                https://www.fast.ai/2017/11/13/validation-sets/






                share|improve this answer











                $endgroup$



                When choosing the validation set and the test set, it is important that it reflects the actual "production environment" of your problem. Since you have "out of time" validation sets, I assume you have some time structure in your data that you need to address when making predictions. If you are developing your model, not taking this time aspect into consideration, you are likely to get issues when this model is put into a realistic environment because the models are fit to an unrealistic scenario where time does not matter.



                From the scores you show here, the train and test scores are very similar, while it drops off in the "out of time"-set. This might be an indication that you are not putting enough emphasis on the time dimension while developing your model.



                Another point: There is also fully possible to overfit to your validation set, when as in your case, you have a lot of variables. Since some combination of these variables might randomly fit your train and validation set well, it might not be the case for your test set. This effect is also magnified by my earlier point, where the data generating process is not really stationary across time.



                Here is a nice article about how to choose a good validation set:
                https://www.fast.ai/2017/11/13/validation-sets/







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 4 at 18:08

























                answered Mar 4 at 18:03









                user10283726user10283726

                13




                13



























                    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%2f46646%2foverfitting-how-to-detect-it-and-reduce-it%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

                    Францішак Багушэвіч Змест Сям'я | Біяграфія | Творчасць | Мова Багушэвіча | Ацэнкі дзейнасці | Цікавыя факты | Спадчына | Выбраная бібліяграфія | Ушанаванне памяці | У філатэліі | Зноскі | Літаратура | Спасылкі | НавігацыяЛяхоўскі У. Рупіўся дзеля Бога і людзей: Жыццёвы шлях Лявона Вітан-Дубейкаўскага // Вольскі і Памідораў з песняй пра немца Адвакат, паэт, народны заступнік Ашмянскі веснікВ Минске появится площадь Богушевича и улица Сырокомли, Белорусская деловая газета, 19 июля 2001 г.Айцец беларускай нацыянальнай ідэі паўстаў у бронзе Сяргей Аляксандравіч Адашкевіч (1918, Мінск). 80-я гады. Бюст «Францішак Багушэвіч».Яўген Мікалаевіч Ціхановіч. «Партрэт Францішка Багушэвіча»Мікола Мікалаевіч Купава. «Партрэт зачынальніка новай беларускай літаратуры Францішка Багушэвіча»Уладзімір Іванавіч Мелехаў. На помніку «Змагарам за родную мову» Барэльеф «Францішак Багушэвіч»Памяць пра Багушэвіча на Віленшчыне Страчаная сталіца. Беларускія шыльды на вуліцах Вільні«Krynica». Ideologia i przywódcy białoruskiego katolicyzmuФранцішак БагушэвічТворы на knihi.comТворы Францішка Багушэвіча на bellib.byСодаль Уладзімір. Францішак Багушэвіч на Лідчыне;Луцкевіч Антон. Жыцьцё і творчасьць Фр. Багушэвіча ў успамінах ягоных сучасьнікаў // Запісы Беларускага Навуковага таварыства. Вільня, 1938. Сшытак 1. С. 16-34.Большая российская1188761710000 0000 5537 633Xn9209310021619551927869394п

                    Partai Komunis Tiongkok Daftar isi Kepemimpinan | Pranala luar | Referensi | Menu navigasidiperiksa1 perubahan tertundacpc.people.com.cnSitus resmiSurat kabar resmi"Why the Communist Party is alive, well and flourishing in China"0307-1235"Full text of Constitution of Communist Party of China"smengembangkannyas

                    ValueError: Expected n_neighbors <= n_samples, but n_samples = 1, n_neighbors = 6 (SMOTE) The 2019 Stack Overflow Developer Survey Results Are InCan SMOTE be applied over sequence of words (sentences)?ValueError when doing validation with random forestsSMOTE and multi class oversamplingLogic behind SMOTE-NC?ValueError: Error when checking target: expected dense_1 to have shape (7,) but got array with shape (1,)SmoteBoost: Should SMOTE be ran individually for each iteration/tree in the boosting?solving multi-class imbalance classification using smote and OSSUsing SMOTE for Synthetic Data generation to improve performance on unbalanced dataproblem of entry format for a simple model in KerasSVM SMOTE fit_resample() function runs forever with no result