Does setting a random state in sklearn's RandomForestClassifier bias your model?Why does this code using random strings print “hello world”?random_state parameter in classification modelsHow to find the accuracy for Survival Analysis using RandomForestSRC package in RHow does one interpret the random forest classifier from sci-kit learn?Why does cross validation RF classification perform worse than without cross validation?Random forest sklearnRandom Forest and ImbalanceUsed SequentialFeatureSelector but does not improve the model accuracyRandom forest: balancing test set?How to find the difference between two Random Forest model instances?

Fair gambler's ruin problem intuition

Why is the sentence "Das ist eine Nase" correct?

Why were 5.25" floppy drives cheaper than 8"?

Is it possible to create a QR code using text?

Notepad++ delete until colon for every line with replace all

What is the fastest integer factorization to break RSA?

How to travel to Japan while expressing milk?

Is this answer explanation correct?

Placement of More Information/Help Icon button for Radio Buttons

GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?

How badly should I try to prevent a user from XSSing themselves?

How to Prove P(a) → ∀x(P(x) ∨ ¬(x = a)) using Natural Deduction

Was the Stack Exchange "Happy April Fools" page fitting with the '90's code?

Does Dispel Magic work on Tiny Hut?

Is it inappropriate for a student to attend their mentor's dissertation defense?

Is there a hemisphere-neutral way of specifying a season?

Did 'Cinema Songs' exist during Hiranyakshipu's time?

What historical events would have to change in order to make 19th century "steampunk" technology possible?

Ambiguity in the definition of entropy

What is required to make GPS signals available indoors?

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

OP Amp not amplifying audio signal

What Exploit Are These User Agents Trying to Use?

What are the G forces leaving Earth orbit?



Does setting a random state in sklearn's RandomForestClassifier bias your model?


Why does this code using random strings print “hello world”?random_state parameter in classification modelsHow to find the accuracy for Survival Analysis using RandomForestSRC package in RHow does one interpret the random forest classifier from sci-kit learn?Why does cross validation RF classification perform worse than without cross validation?Random forest sklearnRandom Forest and ImbalanceUsed SequentialFeatureSelector but does not improve the model accuracyRandom forest: balancing test set?How to find the difference between two Random Forest model instances?













1















I've training a random forest model and am using a consistent random_state value. I'm also getting really good accuracies across my training, test, and validation datasets (all are around ~.98). Though the minority class comprises only ~10% of the dataset.



Here's some code if you're interested:



model = RandomForestClassifier(n_jobs=-1, oob_score=True, random_state=310, n_estimators=300)
model.fit(subset, train.iloc[:,-1])


Given the good accuracy scores across training, validation and testing datsets, does random_state affect the generalization of my model?










share|improve this question




























    1















    I've training a random forest model and am using a consistent random_state value. I'm also getting really good accuracies across my training, test, and validation datasets (all are around ~.98). Though the minority class comprises only ~10% of the dataset.



    Here's some code if you're interested:



    model = RandomForestClassifier(n_jobs=-1, oob_score=True, random_state=310, n_estimators=300)
    model.fit(subset, train.iloc[:,-1])


    Given the good accuracy scores across training, validation and testing datsets, does random_state affect the generalization of my model?










    share|improve this question


























      1












      1








      1








      I've training a random forest model and am using a consistent random_state value. I'm also getting really good accuracies across my training, test, and validation datasets (all are around ~.98). Though the minority class comprises only ~10% of the dataset.



      Here's some code if you're interested:



      model = RandomForestClassifier(n_jobs=-1, oob_score=True, random_state=310, n_estimators=300)
      model.fit(subset, train.iloc[:,-1])


      Given the good accuracy scores across training, validation and testing datsets, does random_state affect the generalization of my model?










      share|improve this question
















      I've training a random forest model and am using a consistent random_state value. I'm also getting really good accuracies across my training, test, and validation datasets (all are around ~.98). Though the minority class comprises only ~10% of the dataset.



      Here's some code if you're interested:



      model = RandomForestClassifier(n_jobs=-1, oob_score=True, random_state=310, n_estimators=300)
      model.fit(subset, train.iloc[:,-1])


      Given the good accuracy scores across training, validation and testing datsets, does random_state affect the generalization of my model?







      random scikit-learn random-forest random-seed






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 9 at 8:59









      AI_Learning

      4,15521035




      4,15521035










      asked Mar 8 at 20:58









      Joe BJoe B

      16812




      16812






















          2 Answers
          2






          active

          oldest

          votes


















          1














          random_state does not affect the generalization of the model. In fact, it is the best practice to have same value for random_state when you tune your hyper parameters such as n_estimators, depth, etc. This will ensure that your performance is not affected by the random initial state.



          Also, Accuracy is not the recommended metrics to measure the performance of the model, when you have such as unbalanced dataset.



          Area under the ROC or PR curve could be one of the few best things you can use but there are a lot of metrics available. See here






          share|improve this answer


















          • 1





            Thanks! just what I was looking for. re accuracy - I'm actually using a confusion matrix to measure for internal metrics, but that is a good point.

            – Joe B
            Mar 9 at 17:26


















          1















          random_state : int, RandomState instance or None, optional (default=None)



          If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.




          In general random_state is be used to set the internal parameters initially, so you can repeat the training deterministically. Now you can change other hyperparameters (e.g. number of trees) to compare the results.



          A disadvantage could be that you don't find the global optimum. But your results sound really good with an accuracy of 0.98.






          share|improve this answer























            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%2f55070918%2fdoes-setting-a-random-state-in-sklearns-randomforestclassifier-bias-your-model%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









            1














            random_state does not affect the generalization of the model. In fact, it is the best practice to have same value for random_state when you tune your hyper parameters such as n_estimators, depth, etc. This will ensure that your performance is not affected by the random initial state.



            Also, Accuracy is not the recommended metrics to measure the performance of the model, when you have such as unbalanced dataset.



            Area under the ROC or PR curve could be one of the few best things you can use but there are a lot of metrics available. See here






            share|improve this answer


















            • 1





              Thanks! just what I was looking for. re accuracy - I'm actually using a confusion matrix to measure for internal metrics, but that is a good point.

              – Joe B
              Mar 9 at 17:26















            1














            random_state does not affect the generalization of the model. In fact, it is the best practice to have same value for random_state when you tune your hyper parameters such as n_estimators, depth, etc. This will ensure that your performance is not affected by the random initial state.



            Also, Accuracy is not the recommended metrics to measure the performance of the model, when you have such as unbalanced dataset.



            Area under the ROC or PR curve could be one of the few best things you can use but there are a lot of metrics available. See here






            share|improve this answer


















            • 1





              Thanks! just what I was looking for. re accuracy - I'm actually using a confusion matrix to measure for internal metrics, but that is a good point.

              – Joe B
              Mar 9 at 17:26













            1












            1








            1







            random_state does not affect the generalization of the model. In fact, it is the best practice to have same value for random_state when you tune your hyper parameters such as n_estimators, depth, etc. This will ensure that your performance is not affected by the random initial state.



            Also, Accuracy is not the recommended metrics to measure the performance of the model, when you have such as unbalanced dataset.



            Area under the ROC or PR curve could be one of the few best things you can use but there are a lot of metrics available. See here






            share|improve this answer













            random_state does not affect the generalization of the model. In fact, it is the best practice to have same value for random_state when you tune your hyper parameters such as n_estimators, depth, etc. This will ensure that your performance is not affected by the random initial state.



            Also, Accuracy is not the recommended metrics to measure the performance of the model, when you have such as unbalanced dataset.



            Area under the ROC or PR curve could be one of the few best things you can use but there are a lot of metrics available. See here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 9 at 8:57









            AI_LearningAI_Learning

            4,15521035




            4,15521035







            • 1





              Thanks! just what I was looking for. re accuracy - I'm actually using a confusion matrix to measure for internal metrics, but that is a good point.

              – Joe B
              Mar 9 at 17:26












            • 1





              Thanks! just what I was looking for. re accuracy - I'm actually using a confusion matrix to measure for internal metrics, but that is a good point.

              – Joe B
              Mar 9 at 17:26







            1




            1





            Thanks! just what I was looking for. re accuracy - I'm actually using a confusion matrix to measure for internal metrics, but that is a good point.

            – Joe B
            Mar 9 at 17:26





            Thanks! just what I was looking for. re accuracy - I'm actually using a confusion matrix to measure for internal metrics, but that is a good point.

            – Joe B
            Mar 9 at 17:26













            1















            random_state : int, RandomState instance or None, optional (default=None)



            If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.




            In general random_state is be used to set the internal parameters initially, so you can repeat the training deterministically. Now you can change other hyperparameters (e.g. number of trees) to compare the results.



            A disadvantage could be that you don't find the global optimum. But your results sound really good with an accuracy of 0.98.






            share|improve this answer



























              1















              random_state : int, RandomState instance or None, optional (default=None)



              If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.




              In general random_state is be used to set the internal parameters initially, so you can repeat the training deterministically. Now you can change other hyperparameters (e.g. number of trees) to compare the results.



              A disadvantage could be that you don't find the global optimum. But your results sound really good with an accuracy of 0.98.






              share|improve this answer

























                1












                1








                1








                random_state : int, RandomState instance or None, optional (default=None)



                If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.




                In general random_state is be used to set the internal parameters initially, so you can repeat the training deterministically. Now you can change other hyperparameters (e.g. number of trees) to compare the results.



                A disadvantage could be that you don't find the global optimum. But your results sound really good with an accuracy of 0.98.






                share|improve this answer














                random_state : int, RandomState instance or None, optional (default=None)



                If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.




                In general random_state is be used to set the internal parameters initially, so you can repeat the training deterministically. Now you can change other hyperparameters (e.g. number of trees) to compare the results.



                A disadvantage could be that you don't find the global optimum. But your results sound really good with an accuracy of 0.98.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 8 at 21:19









                Darius M.Darius M.

                3,50012036




                3,50012036



























                    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%2f55070918%2fdoes-setting-a-random-state-in-sklearns-randomforestclassifier-bias-your-model%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

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme