为什么我的 `train_test_split()` returns 相同的样本

Why does my `train_test_split()` returns same samples

为什么我的 sklearn.model_selection.train_test_split() returns X_trainX_testy_trainy_test 的相同样本每次 运行 代码,即使我保留了 shuffle=True,而且我没有手动定义种子值?

我正在打印这样的样本:

X_train, X_test, y_train, y_test = train_test_split(x, y, test_size = 0.3, random_state = 100, shuffle=True)

print (y_test)

train_test_splitrandom_state控制样本状态(https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html):

Controls the shuffling applied to the data before applying the split. Pass an int for reproducible output across multiple function calls

要获得不同的结果,只需删除参数即可。