python-3.x - 如何在多标签 uskig sklearn 上进行分层测试和训练拆分
问题描述
我正在关注这个链接:
我有一个training
数据框和相应labels
的数据框。这是multi-labelled text classification
问题。多编码向量的维数为45
。
训练数据是形状8000000*5
行。
标签示例:
c_0 c_1 c_2 c_3 ..............c_44
0. 1. 1. 0. .............. 0
0. 1. 0. 1. .............. 1
我正在使用此代码进行训练和测试拆分:
%%时间
为多标签多类分类执行分层抽样
from skmultilearn.model_selection import IterativeStratification
stratifier = IterativeStratification(n_splits=2, order=45, sample_distribution_per_fold=[0.10, 0.90])
train_indexes, test_indexes = next(stratifier.split(sample_data_df,labels_df))
X_train, y_train = sample_data_df.loc[train_indexes], labels_df.loc[train_indexes]
X_test, y_test = sample_data_df.loc[test_indexes], labels_df.loc[test_indexes]
我不明白什么是n_splits=2
和order=45
代表什么。
它也继续运行而不收敛。
有没有更快的方法将这些数据拆分为训练和测试?
解决方案
推荐阅读
- c++ - Boost intrusive list 中有很多编译错误
- r - 分析 R 中的数据,我想将图表导出到 powerpoint
- mono - 如何结合 Mono 和 Flux 作为参数来创建新的 Mono?
- google-chrome - 如何在 Chrome 74+ 中禁用 CORB
- php - 如何将两个 svg 动画放在一列中?
- r - 有没有可以用权重聚类的算法?
- react-native - 如何修改 SafeAreaView 中的填充?
- vue.js - 在 VueJS 中,当我有唯一字符串或数字数组时,是否可以将 :key 属性绑定到元素值?
- mysql - 当我尝试在存储过程中更改表时出现 SQL 错误
- javascript - 表格中每一行的三态切换按钮