Skip to content

Instantly share code, notes, and snippets.

@notha99y
Created December 19, 2018 09:03
Show Gist options
  • Save notha99y/98649300512d7737a075ed42b439433b to your computer and use it in GitHub Desktop.
Save notha99y/98649300512d7737a075ed42b439433b to your computer and use it in GitHub Desktop.
from xgboost import XGBClassifier
xgb_clf = XGBClassifier(max_depth=12, learning_rate=1e-4,n_estimators=500)
xgb_clf.fit(X_train, np.argmax(np.array(y_train), axis = 1))
xgb_y_pred = xgb_clf.predict(X_val)
pd.Series(xgb_clf.feature_importances_, index = X_train.columns).nlargest(12).plot(kind = 'barh',
figsize = (10, 10),
title = 'Feature importance from XGBoost').invert_yaxis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment