scikit-learn - 为什么我的 train_test_split 不适用于分层选项?
问题描述
我在下面运行代码以均匀拆分数据,但数据没有按预期拆分。
from sklearn.model_selection import train_test_split
y_train, y_test = train_test_split(label, test_size = 0.5, stratify= label, random_state=1)
它返回:
y_train.shape = (115956,)
y_test.shape = (22,)
特征形状:(123670, 15),
标签形状:(123670,),
label.value_counts() 返回:
0 123578
1 92
如果我删除分层选项,它工作正常。有人知道为什么吗?我感到很困惑。
Scikit-learn==0.23.1
我真的需要帮助,这个问题一直在杀死我:(
解决方案
推荐阅读
- reactjs - 地图没有显示
- python - Django按日期注释分组返回对象
- python - Windows编写的python脚本在mac上运行时无法导入pandas或numpy;在 Windows 上一切正常
- javascript - 如何通过 Javascript 中的切换类选择元素?
- aframe - 构建 A-Frame 项目文件的公认“最佳实践”方法是什么?
- php - Laravel 中的 PHP 邮件模板,'src' 不适用于标签
- sql - 具有时间间隔的 TSQL 领先
- java - 从 mongodb 访问数据
- amazon-web-services - 如何使我的基于 go daddy 的域名具有 https url?
- java - Java - 从另一个线程获取输入时打印