Plot a Single XGBoost Decision Tree

前端 未结 4 1986
慢半拍i
慢半拍i 2021-01-05 04:13

I am using method on https://machinelearningmastery.com/visualize-gradient-boosting-decision-trees-xgboost-python/ to plot a XGBoost Decision Tree

from numpy         


        
4条回答
  •  温柔的废话
    2021-01-05 04:35

    I had the same problem recently and the only way I found is by trying diffent figure size (it can still be bluery with big figure. For exemple, to plot the 4th tree, use:

    fig, ax = plt.subplots(figsize=(30, 30))
    xgb.plot_tree(model, num_trees=4, ax=ax)
    plt.show()
    

    To save it, you can do

    plt.savefig("temp.pdf")
    

    Also, each tree seperates two classes so you have as many tree as class.

提交回复
热议问题