train_test_split分组
- train_test_split函数用于将矩阵随机划分为训练子集和测试子集,并返回划分好的训练集测试集样本和训练集测试集标签。
- X_train,X_test, y_train, y_test =cross_validation.train_test_split(train_data,train_target,test_size=0.3, random_state=0)
- train_data:被划分的样本特征集
- train_target:被划分的样本标签
- test_size:如果是浮点数,在0-1之间,表示样本占比;如果是整数的话就是样本的数量
- random_state:是随机数的种子
from sklearn.model_selection import train_test_split
cross_val_score
from sklearn.model_selection import cross_val_score
scores = cross_val_score(model, X, y, cv=n_folds)
# cv 设置交叉检验的次数
得到一个一维数组