2016-02-29 75 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均值聚类来按重要性对每个特征进行分组。

或者,这可以用树形图表示(参见上面的链接)。