Why do we set a random state in machine learning models?

random_state=42

Rukshan Pramoditha
Towards Data Science
6 min readApr 30, 2022

--

Image by aalmeidah from Pixabay

You may already use random state in your machine learning models. Do you know that random state is a model hyperparameter used to control the randomness involved in machine learning models?

In Scikit-learn, the random state hyperparameter is denoted by random_state . It usually takes one of the following values.

--

--

3,000,000+ Views | BSc in Stats | Top 50 Data Science, AI/ML Technical Writer on Medium | Data Science Masterclass: https://datasciencemasterclass.substack.com