ML之xgboost:利用xgboost算法(自带方式)训练mushroom蘑菇数据集(22+1,6513+1611)来预测蘑菇是否毒性(二分类预测)
目录
输出结果
设计思路
核心代码
输出结果
1、xgboost(num_trees=0): Binary prediction based on Mushroom Dataset
2、xgboost(num_trees=1): Binary prediction based on Mushroom Dataset
3、xgboost(num_trees=1,max_depth=4): Binary prediction based on Mushroom Dataset
设计思路
数据集:Dataset之mushroom:mushroom蘑菇数据集的简介、下载、使用方法之详细攻略
核心代码
preds = bst.predict(dtest)predictions = [round(value) for value in preds]test_accuracy = accuracy_score(y_test, predictions)print("Test Accuracy: %.2f%%" % (test_accuracy * 100.0))from matplotlib import pyplotimport graphviz# num_trees=0# xgb.plot_tree(bst, num_trees=0, rankdir= 'LR' ) #xgb.to_graphviz(bst,num_trees=0)# num_trees=1xgb.plot_tree(bst,num_trees=1, rankdir= 'LR' )#xgb.to_graphviz(bst,num_trees=1)
ML之xgboost:利用xgboost算法(自带方式)训练mushroom蘑菇数据集(22+1 6513+1611)来预测蘑菇是否毒性(二分类预测)