2016-02-29 81 views
-1

假設數據同時具有數字& catagoricial功能,並且我使用gblinear創建了xgboost模型。我用xgb.importance分析了xgboost模型,那麼如何表達分類變量權重?gblinear xgboost in R

回答

1

雖然XGBoost是considered to be a black box模型,但您可以通過對所有分割樹和所有樹的每個特徵的增益進行平均,來了解特徵重要性(對於分類和數字)。

這表示在下圖中。

# Get the feature real names 
names <- dimnames(trainMatrix)[[2]] 

# Compute feature importance matrix 
importance_matrix <- xgb.importance(names, model = bst) 

# Nice graph 
xgb.plot.importance(importance_matrix[1:10,]) 

enter image description here

在上面的功能重要性,我們可以看到第10個最重要的特點。

此功能爲每個小節賦予一種顏色。基本上應用K均值聚類來按重要性對每個特徵進行分組。

或者,這可以用樹形圖表示(參見上面的鏈接)。