fqj-kylin
9/23/2017 - 10:24 AM

交叉验证

交叉验证

# 计算交叉验证的指标
# array([ 0.96666667,  1.        ,  0.96666667,  0.96666667,  1.        ])
from sklearn.model_selection import cross_val_score
clf=svm.SVC(kernel='linear',C=1)
scores=cross_val_score(clf,iris.data,iris.target,cv=5)#5折交叉验证
pring(scores)

#平均值和95%的置信区间可以计算得出
# Accuary: 0.98(+/-0.03)
print("Accuary: %0.2f(+/-%0.2f)" % (scores.mean(),scores.std()*2))