我不明白在 Train Test split 和 MLP regressor 中更改随机状态之间的区别

I don't understand difference between changing the random state in Train Test split and in the MLP regressor

我试图弄清楚火车测试拆分中的随机状态与 MLP 回归器中的随机状态之间的差异。 如果我在 MLP 回归器中更改它,我 运行 的所有试验都非常好。但是,如果我在火车测试拆分中更改它,我会得到广泛的结果。我读到两者都是随机种子,但我不明白它们对我的 MLP 的影响有何不同,具体取决于我更改它的位置。

感谢您的帮助!

我假设您有一些类似于 scikit-example here:

中的代码
X_train, X_test, y_train, y_test = train_test_split(X, y,random_state=1)
regr = MLPRegressor(random_state=1, max_iter=500).fit(X_train, y_train)

首先你在 train_test_split 中改变了随机状态,然后你在 MLPRegressor 中改变了它并进行了比较。

在 train_test_split 方法中更改 random_state 时,它会根据您的 random_state 对您的数据进行一些不同的洗牌,因此您的训练和测试数据看起来会有所不同。 (Documentation)

当更改 MLPRegressor 的 random_state 时,它不仅会使用该种子在 train_test_split 方法中打乱数据,还会生成权重、初始化偏差并确定批量采样. (Documentation)

因此,在 MLPRegressor 中更改随机状态需要进行的更改不仅仅是更改 train_test_split 随机状态。希望我正确理解了你的问题并能帮助到你。