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

                    Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                    Can't find variable: document ReactNative Js2019 Community Moderator ElectionReactNative: how to center text?Can't find variable: navigate - ReactNative navigationReact Native error: “Can't find variable: TouchableHighlight”How to use Expo.DocumentPicker.getDocumentAsync properly. [Expo] [ReactNative]Can't find variable: regeneratorRuntime (ReactNative)Reactnative Expo It is advisable for a StartUp?Can't find variable : Self / Can't install firebaseNPM Install Error in installing ReactNative CLIContacts Displaying in App using ReactnativeFacebook login error: can't find variable: Alert

                    Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices