0
$\begingroup$

A value of 324 is provided without explanation in a linear regression tutorial that I'm following. I checked to see if this was the number of samples, but they did not match.

Edit: My apologies for such an ill-formed question. The random_state argument is for scikit-learn's train_test_split function.

From the documentation, "If int, random_state is the seed used by the random number generator" so I can see that generating a random number is involved and I'm fairly certain that the utility of generating random numbers is to randomize the samples allocated to training/testing, but what I don't understand is why 324 was chosen.

The tutorial is here: https://www.youtube.com/watch?v=PjbTG5BNzL0&t=601s

$\endgroup$
  • $\begingroup$ This can't be answered without a link to the tutorial. $\endgroup$ – Michael R. Chernick Aug 16 '17 at 20:59
  • $\begingroup$ I marked it as a duplicate of another thread that at first sight may seem very different from what you're asking, but it provides all the answers for your concerns if you read carefully. $\endgroup$ – Tim Jun 13 '18 at 6:02
  • $\begingroup$ TLDR; you can pick any value you want, people usually choose for the seed some number they like for whatever reason. IMPORTANT: this is not a hyperparameter, so don't tune it. $\endgroup$ – Tim Jun 13 '18 at 6:04
3
$\begingroup$

As found in this answer by elyase

If you use random_state=some_number, then you can guarantee that the output of Run 1 will be equal to the output of Run 2, i.e. your split will be always the same. It doesn't matter what the actual random_state number is 42, 0, 21, ... The important thing is that everytime you use 42, you will always get the same output the first time you make the split. This is useful if you want reproducible results, for example in the documentation, so that everybody can consistently see the same numbers when they run the examples. In practice I would say, you should set the random_state to some fixed number while you test stuff, but then remove it in production if you really need a random (and not a fixed) split.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.