code_gender M
flag_own_car Y
flag_own_realty Y
name_income_type Working
name_education_type Secondary / secondary special
name_family_status Married
name_housing_type Co-op apartment
occupation_type Laborers
cnt_children 1
amt_income_total 216000.0
cnt_fam_members 3.0
Name: 226874, dtype: object
Code
# retain features namextrain_processed = preprocessor.transform(xtrain)xtrain_processed = pd.DataFrame(xtrain_processed, columns=config.features)# retain features namextest_processed = preprocessor.transform(xtest)xtest_processed = pd.DataFrame(xtest_processed, columns=config.features)# retain features namexgb_clf.get_booster().feature_names = config.features# convert to DMatrixdtrain = DMatrix(xtrain_processed, label=ytrain)dtest = DMatrix(xtest_processed, label=ytest)# usefol idxsidx = [15454, 1284, 30305]x_processed = preprocessor.transform(x)
## Features importance
Code
from xgboost import plot_importanceplot_importance( booster=xgb_clf.get_booster(), grid=False, importance_type="gain", title="Feature Importance by Gain", values_format="{v:.2f}")plt.savefig("plot_importance.jpeg", dpi=200)plt.show()plt.close()