您当前的位置: 首页 >  算法
  • 0浏览

    0关注

    2393博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

ML之xgboost:利用xgboost算法(自带方式)训练mushroom蘑菇数据集(22+1,6513+1611)来预测蘑菇是否毒性(二分类预测)

一个处女座的程序猿 发布时间:2019-05-23 22:09:50 ,浏览量:0

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 pyplot
import graphviz

# num_trees=0
# xgb.plot_tree(bst, num_trees=0, rankdir= 'LR' )  
#xgb.to_graphviz(bst,num_trees=0)


# num_trees=1
xgb.plot_tree(bst,num_trees=1, rankdir= 'LR' )
#xgb.to_graphviz(bst,num_trees=1)

 

 

 

关注
打赏
1664196048
查看更多评论
立即登录/注册

微信扫码登录

0.0555s