plotting the tree in XGBoost
1
0
Entering edit mode
3.7 years ago
mrashad ▴ 80

Dear all,

I am new in machine learning and used XGBoost classifier, while plotting the tree, I found 2 codes:

xgb.plot_tree(model, num_trees=5)
xgb.plot_tree(model)

What is the difference between both codes for plotting the tree?

By searching, I found that the first code for plotting the 5th boosted tree, but I couldn't understand.

Thanks in advance

XGBoost • 1.2k views
ADD COMMENT
1
Entering edit mode
3.7 years ago
Mensur Dlakic ★ 28k

You will get a number of trees as a result of (extreme) gradient tree boosting - the exact number depends on how many iterations were done before the training was stopped. Since there are almost always hundreds of trees (and sometimes thousands) in the final model, the plot_tree function will allow the printing of any of the trees.

The first line you show will print the 6th tree (tree index starts with 0). If you don't specify the num_trees parameter, it will plot the first tree (index 0). It is easy to find this information in API documentation for XGBoost.

ADD COMMENT
0
Entering edit mode

Thanks a lot for this fruitful and helpful answer.

ADD REPLY

Login before adding your answer.

Traffic: 2522 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6