楼主: 我是小趴菜
326 0

[数据挖掘新闻] pytho测试拆分的优点 [推广有奖]

  • 0关注
  • 4粉丝

教授

35%

还不是VIP/贵宾

-

威望
0
论坛币
29650 个
通用积分
380.5350
学术水平
1 点
热心指数
1 点
信用等级
0 点
经验
7150 点
帖子
670
精华
0
在线时间
37 小时
注册时间
2022-8-30
最后登录
2023-4-4

楼主
我是小趴菜 发表于 2022-10-31 16:10:28 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
  • 可以在与用于训练的数据不同的数据上训练和测试模型。
  • 响应值对于测试数据集是已知的,因此可以评估预测
  • 测试精度是比样本外性能的训练准确性更好的估计。

# load the iris dataset as an example

from sklearn.datasets import load_iris

iris = load_iris()


# store the feature matrix (X) and response vector (y)

X = iris.data

y = iris.target


# splitting X and y into training and testing sets

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.4, random_state=1)


# printing the shapes of the new X objects

print(X_train.shape)

print(X_test.shape)


# printing the shapes of the new y objects

print(y_train.shape)

print(y_test.shape)


输出:

(90L, 4L)
(60L, 4L)
(90L,)
(60L,)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Selection printing datasets Training response

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-2-5 08:27