Random_state parameter

I don’t understand to what random_state parameter corresponds exactly and how to set it? What does “42” means exactly?
Thank you

1 Like

The train_test_split by default selects a random subset of the data for testing. Without setting the random_state, a different random subset will be selected each time you run the cell of code.

Setting the random_state parameter allows in general to get deterministic results when we use a random number generator. In this sense, the number “42” is an arbitrary number that you can provide to other people for them to reproduce your results.

I hope this will be clearer when you watch the video “Validation of a model”.

1 Like

More importantly, it’s the answer to the Ultimate Question of Life, the Universe, and Everything.

1 Like

Sounds like you were waiting for this question your whole life :laughing:

OK, thank you for your answer!