【发布时间】:2021-07-15 02:34:21
【问题描述】:
我一直在使用 Scikit learn 编写一些用于信用卡欺诈检测问题的代码。 我使用 train_test_split 将数据拆分为训练、测试和验证数据集。
x_train,x_test,y_train,y_test=train_test_split(x,y,train_size=0.7,random_state=123)
我不明白为什么这里的 random_state 是 123 同时在训练和测试数据集之间分割数据和
part_x_train, x_val, part_y_train, y_val = train_test_split(x_train, y_train, test_size=0.2, random_state=2)
这里 random_state 为 2,同时在训练和验证数据集之间拆分数据。为什么差别这么大? 我一直在尝试使用不同的 random_states,但无法找出区别。
【问题讨论】:
-
你读过the docs这个函数吗?使用该参数的原因在此处定义:“在应用拆分之前控制应用于数据的改组。传递一个 int 以实现跨多个函数调用的可重现输出。” (强调)读完之后,您的具体问题是什么?
标签: python machine-learning scikit-learn train-test-split