Is max_depth in scikit the equivalent of pruning in decision trees?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I was analyzing the classifier created using a decision tree. There is a tuning parameter called max_depth in scikit's decision tree. Is this equivalent of pruning a decision tree? If not, how could I prune a decision tree using scikit?



dt_ap = tree.DecisionTreeClassifier(random_state=1, max_depth=13)
boosted_dt = AdaBoostClassifier(dt_ap, random_state=1)
boosted_dt.fit(X_train, Y_train)









share|improve this question

























    up vote
    2
    down vote

    favorite












    I was analyzing the classifier created using a decision tree. There is a tuning parameter called max_depth in scikit's decision tree. Is this equivalent of pruning a decision tree? If not, how could I prune a decision tree using scikit?



    dt_ap = tree.DecisionTreeClassifier(random_state=1, max_depth=13)
    boosted_dt = AdaBoostClassifier(dt_ap, random_state=1)
    boosted_dt.fit(X_train, Y_train)









    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I was analyzing the classifier created using a decision tree. There is a tuning parameter called max_depth in scikit's decision tree. Is this equivalent of pruning a decision tree? If not, how could I prune a decision tree using scikit?



      dt_ap = tree.DecisionTreeClassifier(random_state=1, max_depth=13)
      boosted_dt = AdaBoostClassifier(dt_ap, random_state=1)
      boosted_dt.fit(X_train, Y_train)









      share|improve this question













      I was analyzing the classifier created using a decision tree. There is a tuning parameter called max_depth in scikit's decision tree. Is this equivalent of pruning a decision tree? If not, how could I prune a decision tree using scikit?



      dt_ap = tree.DecisionTreeClassifier(random_state=1, max_depth=13)
      boosted_dt = AdaBoostClassifier(dt_ap, random_state=1)
      boosted_dt.fit(X_train, Y_train)






      machine-learning python scikit-learn decision-trees supervised-learning






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 5 hours ago









      Suhail Gupta

      1907




      1907




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote














          Is this equivalent of pruning a decision tree?




          Though they have similar goals (i.e. placing some restrictions to the model so that it doesn't grow very complex and overfit), max_depth isn't equivalent to pruning. The way pruning usually works is that go back through the tree and replace branches that do not help with leaf nodes.




          If not, how could I prune a decision tree using scikit?




          You can't through scikit-learn (without altering the source code).

          Quote taken from the Decision Tree documentation: Mechanisms such as pruning (not currently supported)



          If you want to post-prune a tree you have to do it on your own:

          You can read this excellent post detailing how to do so.






          share|improve this answer




















            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            noCode: 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%2f38666%2fis-max-depth-in-scikit-the-equivalent-of-pruning-in-decision-trees%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote














            Is this equivalent of pruning a decision tree?




            Though they have similar goals (i.e. placing some restrictions to the model so that it doesn't grow very complex and overfit), max_depth isn't equivalent to pruning. The way pruning usually works is that go back through the tree and replace branches that do not help with leaf nodes.




            If not, how could I prune a decision tree using scikit?




            You can't through scikit-learn (without altering the source code).

            Quote taken from the Decision Tree documentation: Mechanisms such as pruning (not currently supported)



            If you want to post-prune a tree you have to do it on your own:

            You can read this excellent post detailing how to do so.






            share|improve this answer
























              up vote
              2
              down vote














              Is this equivalent of pruning a decision tree?




              Though they have similar goals (i.e. placing some restrictions to the model so that it doesn't grow very complex and overfit), max_depth isn't equivalent to pruning. The way pruning usually works is that go back through the tree and replace branches that do not help with leaf nodes.




              If not, how could I prune a decision tree using scikit?




              You can't through scikit-learn (without altering the source code).

              Quote taken from the Decision Tree documentation: Mechanisms such as pruning (not currently supported)



              If you want to post-prune a tree you have to do it on your own:

              You can read this excellent post detailing how to do so.






              share|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote










                Is this equivalent of pruning a decision tree?




                Though they have similar goals (i.e. placing some restrictions to the model so that it doesn't grow very complex and overfit), max_depth isn't equivalent to pruning. The way pruning usually works is that go back through the tree and replace branches that do not help with leaf nodes.




                If not, how could I prune a decision tree using scikit?




                You can't through scikit-learn (without altering the source code).

                Quote taken from the Decision Tree documentation: Mechanisms such as pruning (not currently supported)



                If you want to post-prune a tree you have to do it on your own:

                You can read this excellent post detailing how to do so.






                share|improve this answer













                Is this equivalent of pruning a decision tree?




                Though they have similar goals (i.e. placing some restrictions to the model so that it doesn't grow very complex and overfit), max_depth isn't equivalent to pruning. The way pruning usually works is that go back through the tree and replace branches that do not help with leaf nodes.




                If not, how could I prune a decision tree using scikit?




                You can't through scikit-learn (without altering the source code).

                Quote taken from the Decision Tree documentation: Mechanisms such as pruning (not currently supported)



                If you want to post-prune a tree you have to do it on your own:

                You can read this excellent post detailing how to do so.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 51 mins ago









                Djib2011

                1,742516




                1,742516



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f38666%2fis-max-depth-in-scikit-the-equivalent-of-pruning-in-decision-trees%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery