ML之xgboost:利用xgboost算法(sklearn+7CrVa)训练mushroom蘑菇数据集(22+1,6513+1611)来预测蘑菇是否毒性(二分类预测)
作者:互联网
ML之xgboost:利用xgboost算法(sklearn+7CrVa)训练mushroom蘑菇数据集(22+1,6513+1611)来预测蘑菇是否毒性(二分类预测)
目录
输出结果
设计思路
核心代码
kfold = StratifiedKFold(n_splits=10, random_state=7)
#fit_params = {'eval_metric':"logloss"}
#results = cross_val_score(bst, X_train, y_train, cv=kfold, fit_params)
results = cross_val_score(bst, X_train, y_train, cv=kfold)
print(results)
print("7-CrVa Accuracy Mean(STD): %.2f%% (%.2f%%)" % (results.mean()*100, results.std()*100)) #输出
x = range(0,len(results))
y1 = results
y2 = [results.mean()]*10
Xlabel = 'n_splits'
Ylabel = 'Accuracy'
title = 'mushroom datase: xgboost(sklearn+7CrVa) model'
plt.plot(x,y1,'g') #绘制曲线
plt.plot(x,y2,'r--') #平均值曲线
plt.xlabel(Xlabel)
plt.ylabel(Ylabel)
plt.title(title)
plt.show()
标签:plt,6513,mushroom,kfold,xgboost,results,train,蘑菇 来源: https://blog.51cto.com/u_14217737/2905658