使用sklearn划分训练集、验证集、测试集
train_rate,val_rate分别代表训练集、验证集比例from sklearn.model_selection import train_test_splittrain_idx, val_test_idx, _, y_validate_test = train_test_split(index, labels, stratify=labels, train_size=train_rate
·
train_rate,val_rate分别代表训练集、验证集比例
from sklearn.model_selection import train_test_split
train_idx, val_test_idx, _, y_validate_test = train_test_split(index, labels, stratify=labels, train_size=train_rate,test_size=1-train_rate,
random_state=2, shuffle=True)
val_idx, test_idx, _, _ = train_test_split(val_test_idx,y_validate_test, train_size=val_rate/(1-train_rate), test_size=1-val_rate/(1-train_rate),
random_state=2, shuffle=True)
更多推荐
已为社区贡献6条内容
所有评论(0)