-2

I have seen ML tutorials using a parameter called random_states. Why and how this parameter can make changes in the model?

from sklearn.tree import DecisionTreeRegressor

melbourne_model = DecisionTreeRegressor(random_state=1)

melbourne_model.fit(X, y)
desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • Does this answer your question: [random-state-pseudo-random-number-in-scikit-learn](https://stackoverflow.com/questions/28064634/random-state-pseudo-random-number-in-scikit-learn)? – Adarsh Wase Oct 20 '21 at 14:29
  • "*I was recently on a course on Intro to ML on kaggle, where I came across a tutorial on ML Model, in which they used [this and that] - Thanking you*" makes for more **noise** than signal in the question (edited out); in the future, please avoid unnecessary & irrelevant intros, storytelling, thanks etc, and focus only on the issue. Clutter does not help - on the contrary, it is unhelpful and annoying. – desertnaut Oct 20 '21 at 15:08
  • Ok, will take care of it... thank you – A S Adithiyaa Oct 28 '21 at 00:59

1 Answers1

0

The random_state parameter essentially acts as a "seed." Because some ML models depend on random number generation to do things like initialize variables or optimize functions, sometimes training the same algorithm on the same data twice will yield different parameters if they were initialized differently or optimized differently. To control this, engineers will set the random_state parameter to a constant for repeatability purposes.

dsillman2000
  • 976
  • 1
  • 8
  • 20