数据集介绍

数据集划分

  • 训练数据:用于训练,构建模型
  • 测试数据:在模型检验时使用,用于评估模型是否有效

划分比例:

  • 训练集:70% 80% 75%
  • 测试集:30% 20% 30%

API

  • sklearn.model_selection.train_test_split(arrays, *options)
    • x 数据集的特征值
    • y 数据集的标签值(目标值)
    • test_size 测试集的大小,一般为float
    • random_state 随机数种子,不同的种子会造成不同的随机采样结果。相同的种子采样结果相同。
    • return ,训练集特征值,测试集特征值,训练集目标值,测试集目标值
x_train, x_test, y_train, y_test = train_test_split(iris.data, iris.target, random_state=22)

更多文章请关注《万象专栏》