der xgboost plotting API heißt es:XGBoost Grundstück Bedeutung hat keine Eigenschaft max_num_features
xgboost.plot_importance(booster, ax=None, height=0.2, xlim=None, ylim=None, title='Feature importance', xlabel='F score', ylabel='Features', importance_type='weight', max_num_features=None, grid=True, **kwargs)¶
Grundstück Bedeutung basierend auf Einbau Bäumen.
Parameter: aber
booster (Booster, XGBModel or dict) – Booster or XGBModel instance, or dict taken by Booster.get_fscore()
...
max_num_features (int, default None) – Maximum number of top features displayed on plot. If None, all features will be displayed.
In meiner Implementierung, Laufen:
booster_ = XGBClassifier(learning_rate=0.1, max_depth=3, n_estimators=100,
silent=False, objective='binary:logistic', nthread=-1,
gamma=0, min_child_weight=1, max_delta_step=0, subsample=1,
colsample_bytree=1, colsample_bylevel=1, reg_alpha=0,
reg_lambda=1, scale_pos_weight=1, base_score=0.5, seed=0)
booster_.fit(X_train, y_train)
from xgboost import plot_importance
plot_importance(booster_, max_num_features=10)
Returns:
AttributeError: Unknown property max_num_features
Während des Laufens ohne den Parameter max_num_features
Plots korrekt das gesamte Feature-Set (was in meinem Fall gigantisch ist, ~ 10k Features). Irgendwelche Ideen von was ist los?
Vielen Dank im Voraus.
Details:
def feat_imp(df, model, n_features):
d = dict(zip(df.columns, model.feature_importances_))
ss = sorted(d, key=d.get, reverse=True)
top_names = ss[0:n_features]
plt.figure(figsize=(15,15))
plt.title("Feature importances")
plt.bar(range(n_features), [d[i] for i in top_names], color="r", align="center")
plt.xlim(-1, n_features)
plt.xticks(range(n_features), top_names, rotation='vertical')
feat_imp(filled_train_full, booster_, 20)
Yep! XGboost hat nicht die nettesten Dokumente, aber nachdem ich herausgefunden hatte, dass es funktionierte. Ich akzeptiere deine Antwort, da sie jetzt relevanter ist (irgendwie habe ich vergessen, diese Frage gestellt zu haben). –