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)
CodePudding user response:
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.