【发布时间】:2019-04-10 11:46:35
【问题描述】:
我正在使用 scikit-learn 的 train_test_split 功能,并且在重复运行相同的代码时得到不同的结果:
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.1, random_state=42)
当我在y_train 中记录唯一元素的数量时:
logger.info(len(set(y_train)))
我在重复运行时得到不同的值(没有代码更改)。我原以为random_state 会确保确定性拆分。
我怎样才能确保每次都进行相同的拆分?
【问题讨论】:
标签: python scikit-learn