random_states 机器学习模型中的参数

random_states parameter in Machine Learning Models

我看过使用名为 random_states 的参数的 ML 教程。这个参数为什么以及如何改变模型?

from sklearn.tree import DecisionTreeRegressor

melbourne_model = DecisionTreeRegressor(random_state=1)

melbourne_model.fit(X, y)

random_state 参数本质上充当“种子”。由于某些 ML 模型依赖于随机数生成来执行诸如初始化变量或优化函数之类的操作,因此有时如果对相同的数据进行不同的初始化或优化,则对相同的算法进行两次训练会产生不同的参数。为了控制这一点,工程师将 random_state 参数设置为常量以实现可重复性。