Pythonで学ぶクレジットリスクモデリング
Michael Crabtree
Data Scientist, Ford Motor Company
# 特定の列のみを選択
X_multi = cr_loan_prep[['loan_int_rate','person_emp_length']]
# loan_status 以外の全データを選択
X = cr_loan_prep.drop('loan_status', axis = 1)
.get_booster() と .get_score() を使用# モデル学習
clf_gbt.fit(X_train,np.ravel(y_train))
# 特徴量重要度を表示
clf_gbt.get_booster().get_score(importance_type = 'weight')
{'person_home_ownership_RENT': 1, 'person_home_ownership_OWN': 2}
# importance_type = 'weight' の重要度
{'person_home_ownership_RENT': 1, 'person_home_ownership_OWN': 2}
plot_importance() を使用xgb.plot_importance(clf_gbt, importance_type = 'weight')
{'person_income': 315, 'loan_int_rate': 195, 'loan_percent_income': 146}
| 列 | 重要度 | モデル精度 | デフォルト再現率 |
|---|---|---|---|
| loan_int_rate, person_emp_length | (100, 100) | 0.81 | 0.67 |
| loan_int_rate, person_emp_length, loan_percent_income | (98, 70, 5) | 0.84 | 0.52 |
classification_report() に含まれますPythonで学ぶクレジットリスクモデリング