与信リスクの列選択

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)
  • 各列の重要度の見方
    • ロジスティック回帰: 係数
    • 勾配ブースティング木: ?
Pythonで学ぶクレジットリスクモデリング

列の重要度

  • .get_booster().get_score() を使用
    • weight: 列が全木で現れる回数
# モデル学習
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}
Pythonで学ぶクレジットリスクモデリング

列重要度の解釈

# importance_type = 'weight' の重要度
{'person_home_ownership_RENT': 1, 'person_home_ownership_OWN': 2}

XGBoostによる決定木

Pythonで学ぶクレジットリスクモデリング

列重要度のプロット

  • plot_importance() を使用
xgb.plot_importance(clf_gbt, importance_type = 'weight')
{'person_income': 315, 'loan_int_rate': 195, 'loan_percent_income': 146}

特徴量重要度のプロット

Pythonで学ぶクレジットリスクモデリング

学習に使う列の選定

  • 列重要度は、学習に使う列の選定に用いることがあります
  • 列の組み合わせでモデル性能は変わります
重要度 モデル精度 デフォルト再現率
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
Pythonで学ぶクレジットリスクモデリング

モデルのF1スコア

  • 列グループごとに精度と再現率を検討するのは手間がかかる
  • F1スコアは精度と再現率を同時に見る単一指標です

F1スコアの式

  • classification_report() に含まれます

F1スコアを強調した分類レポート

Pythonで学ぶクレジットリスクモデリング

Let's practice!

Pythonで学ぶクレジットリスクモデリング

Preparing Video For Download...