日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Python之 sklearn:sklearn中的train_test_split函数的简介及使用方法之详细攻略

發布時間:2025/3/21 python 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python之 sklearn:sklearn中的train_test_split函数的简介及使用方法之详细攻略 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Python之 sklearn:sklearn中的train_test_split函數的簡介及使用方法之詳細攻略

?

?

?

目錄

sklearn中的train_test_split函數的簡介

train_test_split使用方法

1、基礎用法


?

?

?

sklearn中的train_test_split函數的簡介

官方文檔:https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html?highlight=train_test_split#sklearn.model_selection.train_test_split

sklearn.model_selection.train_test_split(*arrays, **options)[source]
Split arrays or matrices into random train and test subsets
Quick utility that wraps input validation and next(ShuffleSplit().split(X, y)) and application to input data into a single call for splitting (and optionally subsampling) data in a oneliner.

sklearn.model_selection.train_test_split(*數組,* *選項)[源]
將數組或矩陣分割成隨機的序列和測試子集
包裝輸入驗證和next的快速實用程序(ShuffleSplit())。拆分(X, y))和應用程序將數據輸入到單個調用中,以便在oneliner中拆分(和可選的子采樣)數據。

Parameters
*arrays:sequence of indexables with same length / shape[0]
Allowed inputs are lists, numpy arrays, scipy-sparse matrices or pandas dataframes.

test_size:float or int, default=None
If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the test split. If int, represents the absolute number of test samples. If None, the value is set to the complement of the train size. If train_size is also None, it will be set to 0.25.

train_size:float or int, 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.

random_state:int or RandomState instance, default=None
Controls the shuffling applied to the data before applying the split. Pass an int for reproducible output across multiple function calls. See Glossary.

shuffle:bool, default=True
Whether or not to shuffle the data before splitting. If shuffle=False then stratify must be None.

stratify:array-like, default=None
If not None, data is split in a stratified fashion, using this as the class labels.

參數
*arrays:相同長度/形狀的索引表的序列
允許的輸入是列表、numpy數組、scipy稀疏矩陣或panda數據矩陣。

test_size:float或int,默認=無
如果是浮動的,則應該在0.0和1.0之間,并表示要包含在測試分割中的數據集的比例。如果int,表示測試樣本的絕對數量。如果沒有,則將該值設置為列車大小的補充。如果train_size也是None,那么它將被設置為0.25。

train_size:float或int,默認為無
如果是浮點數,則應該在0.0和1.0之間,并表示要包含在分割序列中的數據集的比例。如果int,表示列車樣本的絕對數量。如果沒有,該值將自動設置為測試大小的補充。

random_state:int或RandomState實例,默認為None
控制在應用分割之前應用于數據的變換。在多個函數調用之間傳遞可重復輸出的int。看到術語表。

shuffle:bool,默認= True
是否在拆分前打亂數據。如果shuffle=False,則層必須為None。

stratify:array-like默認=沒有
如果沒有,則以分層的方式分割數據,并將其用作類標簽。

Returns
splitting:list, length=2 * len(arrays)
List containing train-test split of inputs.

New in version 0.16: If the input is sparse, the output will be a scipy.sparse.csr_matrix. Else, output type is the same as the input type.

返回
splitting:list, length=2 *
列表包含訓練測試的輸入分割。

版本0.16中的新內容:如果輸入是稀疏的,則輸出將是scipy.sparse.csr_matrix.。否則,輸出類型與輸入類型相同。

?

train_test_split使用方法

1、基礎用法

>>> import numpy as np >>> from sklearn.model_selection import train_test_split >>> X, y = np.arange(10).reshape((5, 2)), range(5) >>> X array([[0, 1],[2, 3],[4, 5],[6, 7],[8, 9]]) >>> list(y) [0, 1, 2, 3, 4] >>> >>> X_train, X_test, y_train, y_test = train_test_split( ... X, y, test_size=0.33, random_state=42) ... >>> X_train array([[4, 5],[0, 1],[6, 7]]) >>> y_train [2, 0, 3] >>> X_test array([[2, 3],[8, 9]]) >>> y_test [1, 4] >>> >>> train_test_split(y, shuffle=False) [[0, 1, 2], [3, 4]]

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

總結

以上是生活随笔為你收集整理的Python之 sklearn:sklearn中的train_test_split函数的简介及使用方法之详细攻略的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产精品偷乱一区二区三区 | 超碰在线99| 青青操在线观看 | 波多野结衣久久 | 亚洲顶级毛片 | 小泽玛利亚一区二区三区在线观看 | 天堂色区 | 久久sp | 久久久久久国产精品免费免费 | 中文字幕国产一区二区 | 成人拍拍拍| 樱花动漫无圣光 | 在线国产一区二区三区 | 亚洲影院在线播放 | 久久中文字幕在线观看 | 中文字幕一区二区三区四区 | 91av短视频| 日韩三级中文 | 男人天堂网在线观看 | 雪白的扔子视频大全在线观看 | 久久高清无码电影 | 精品一区二区久久 | 狼人精品一区二区三区在线 | 成人免费在线观看av | 久操网在线 | 深夜福利在线免费观看 | 国产一级特黄视频 | 91亚洲精品乱码久久久久久蜜桃 | 一级片在线免费观看 | 日本少妇性高潮 | jizzjizz日本人 | 精品国产18久久久久久 | 五月婷婷综合网 | 欧美精品videos | 一本之道高清无码视频 | 美女日日日 | 插插插干干干 | 日本人妻熟妇久久久久久 | 天天干天天操天天舔 | 国产chinese中国hdxxxx | 国产日韩一区二区在线 | 久久一卡二卡 | 国产一区二区视频在线免费观看 | 五月天激情四射 | 苍井空浴缸大战猛男120分钟 | 亚洲美女一级片 | 成人午夜视频在线 | 色婷婷狠狠操 | 成都4电影免费高清 | 操操久久 | 国产精品三级久久久久久电影 | 日韩一区二区不卡 | 自拍偷拍20p | 136福利视频导航 | 日韩精品一区不卡 | 影音先锋每日资源 | 天天宗合网 | 日韩av在线中文字幕 | 欧美成人自拍 | 日韩欧美一区二区区 | 欧美激情一区在线 | 一级性毛片 | 中国女人内96xxxxx | 午夜影院在线观看视频 | 欧美日韩一区二区精品 | 最新成人在线 | 欧美天天影院 | 欧美日韩精品在线观看视频 | 欧美成人免费在线 | 麻豆免费网站 | 日本免费在线观看视频 | 亚洲欧洲日韩av | 男女羞羞无遮挡 | 亚洲黄一区 | 国产精品99无码一区二区视频 | 欧美三级影院 | 长篇高h乱肉辣文 | 成人片黄网站色大片免费毛片 | 午夜av免费看 | 三级黄色片免费 | 蜜桃精品一区二区 | 亚洲社区在线 | 99操| 99在线精品免费视频 | 国产无遮挡又黄又爽免费视频 | 小辣椒导航 | 一区二区免费播放 | 影音先锋人妻啪啪av资源网站 | 成人午夜电影网站 | 国产精品xxx在线 | 婷婷五月情 | 欧美日韩免费在线视频 | 好男人www日本| 男人看片网站 | 91日韩欧美 | 精品视频大全 | 国产剧情av引诱维修工 | 欧美一区二区高清 | 久久伊人在|