xgb = XGBRegressor(n_estimators=100, learning_rate=0.08, gamma=0,
subsample=0.75, colsample_bytree=1, max_depth=7)
xgb.get_booster().get_score(importance_type='weight')
xgb.feature_importances_
这将返回带有权重的 xgb 的特征重要性,但是如何使用列名返回呢?
xgb = XGBRegressor(n_estimators=100, learning_rate=0.08, gamma=0,
subsample=0.75, colsample_bytree=1, max_depth=7)
xgb.get_booster().get_score(importance_type='weight')
xgb.feature_importances_
这将返回带有权重的 xgb 的特征重要性,但是如何使用列名返回呢?
如果您有X_trainDataframe,那么您可以从那里获取列并使用feature_importances_
for col,score in zip(X_train.columns,model.feature_importances_):
print(col,score)