当前位置:网站首页>[sklearn] data set split sklearn moduel_ selection. train_ test_ split
[sklearn] data set split sklearn moduel_ selection. train_ test_ split
2022-07-22 02:32:00 【Enzo wants to smash the computer】
function
X_train,X_test, y_train, y_test = sklearn.model_selection.train_test_split(X, y,
test_size=None,
train_size=None,
random_state=None,
shuffle=True,
stratify=None)
Parameters :
- X: Sample feature set to be divided
- y: Label of the sample to be divided
- test_size: If in 0~1 Between , Is the ratio of the number of samples in the test set to the number of original samples ; If integer , Is the number of test set samples .
- random_state: Random number seed , Default not set . If it is not set , The test data set segmented from each run is random ; Set it up , Each run is divided into the same result . Different seeds have different results , The results of the same seed running are the same .
Return value
- X_train Divided training set data ( Return value )
- X_test Divided test set data ( Return value )
- y_train Divided training set label ( Return value )
- y_test Divided test set label ( Return value )
give an example :
import numpy as np
from sklearn.model_selection import train_test_split
X, y = np.arange(20).reshape((10, 2)), np.arange(10)
X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.33, random_state=12)
print('X\n',X)
print('\n y \n',y)
print('\n X_train \n',X_train)
print('\n X_test \n',X_test)
print('\n y_train \n',y_train)
print('\n y_test \n',y_test)
边栏推荐
- Static routing principle and configuration
- mysql进阶(十四) 批量更新与批量更新多条记录的不同值实现方法
- 辛丑年之万家灯火
- Resolved (selenium operation Firefox browser error) typeerror:__ init__ () got an unexpected keyword argument ‘firefox_ options‘
- DHCP protocol
- CONDA create, view, delete virtual environment
- excel if 判读单元格如果为空就不参与计算
- 交换机DHCP服务器配置方法(命令行版)
- DHCP协议
- JS object: several ways to implement inheritance and their advantages and disadvantages
猜你喜欢
How the computer accesses the Internet (I) message generation DNS
Value extraction in template and generic programming
[academic related] recommended by Chen Tianqi, Wang William and others: a little advice from the winner of ACL best paper award to new researchers
3564. Date category
Static routing principle and configuration
VLAN与三层交换机
How does the computer access the Internet (II) from network cable to network equipment
SQL basic statement exercise
SQL每日一练(牛客新题库)——第3天: 条件查询
小米12S Ultra产品力这么强老外却买不到 雷军:先专心做好中国市场
随机推荐
【西瓜书学习】1、决策树
Research and practice of field data model based on 3D GIS
mysql进阶(十四) 批量更新与批量更新多条记录的不同值实现方法
H3C交换机查看相关的命令
基于深度神经网络的中药材识别
C load and display menu
交换机DHCP服务器配置方法(命令行版)
Hmailserver enables authentication to prevent spam harassment
Interview Beijing XX technology summary
电脑是怎样上网的 (二) 从网线到网络设备
Mqtt source code analysis
VMware Workstation Pro virtual machine network three types of network cards and their usage
After 2 days of obsolescence, Microsoft gave up "banning" commercial open source!
【H3C设备组网配置】
R language uses fmsb package to visualize radar chart (radar chart, spider plot), independently display radar charts of multiple data objects, add average gray areas, and compare each radar chart with
conda创建、查看、删除虚拟环境
On Newton iteration
SQL server数据库增量更新是根据 where 子句来识别的吗? 那做不到流更新吧? 每个表要
Ancient Chinese civilization
hMailServer开启身份验证,防止垃圾邮件骚扰