【模型评估与选择】sklearn.model_selection.train_test_split

本文介绍了如何利用sklearn.model_selection.train_test_split函数将数据集随机划分为训练集和测试集。该函数接受比例或绝对数量作为参数,可以设定随机种子,并支持分层抽样。返回值包括训练集和测试集的分割结果。文中还提供了实例展示如何使用该函数,并展示了划分后的X_train、X_test、y_train和y_test。
摘要由CSDN通过智能技术生成

1. 描述
Split arrays or matrices into random train and test subsets

2. 语法
train_test_split(*arrays, **options)

3. 参数
1.*arrays:(sequence of indexables with same length / shape[0])
Allowed inputs are lists, numpy arrays, scipy-sparse matrices or pandas dataframes.
2.test_size :(float, int, or None, default None)
If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the train split.
If int, represents the absolute number of train samples.
If None, the value is automatically set to the complement of the test size.
3.random_state :(int, RandomState instance or None, optional (default=None))
If int, random_state is the seed used by the random number generator;
If None, the random number generator is the RandomSt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值