[英]XGBoost decision tree selection
我有一個問題,我應該從XGBoost
選擇XGBoost
。
我將使用以下代碼作為示例。
#import packages
import xgboost as xgb
import matplotlib.pyplot as plt
# create DMatrix
df_dmatrix = xgb.DMatrix(data = X, label = y)
# set up parameter dictionary
params = {"objective":"reg:linear", "max_depth":2}
#train the model
xg_reg = xgb.train(params = params, dtrain = df_dmatrix, num_boost_round = 10)
#plot the tree
xgb.plot_tree(xg_reg, num_trees = n) # my question related to here
我在xg_reg
模型中創建了10棵樹,並且可以通過在上一個代碼中將n
設置為等於樹的索引來繪制其中的任何一棵。
我的問題是:我怎么知道哪棵樹最能解釋數據集? 它總是最后一個嗎? 還是應該確定要包含在樹中的要素,然后選擇包含要素的樹?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.