信贷通过率

Python 信用风险建模

Michael Crabtree

Data Scientist, Ford Motor Company

阈值与贷款状态

  • 之前我们为一组 prob_default 设定了阈值
    • 用于调整贷款的预测 loan_status
preds_df['loan_status'] = preds_df['prob_default'].apply(lambda x: 1 if x > 0.4 else 0)
Loan prob_default threshold loan_status
1 0.25 0.4 0
2 0.42 0.4 1
3 0.75 0.4 1
Python 信用风险建模

阈值与接受率

  • 用模型预测来设定更优阈值
    • 也可用于批准或拒绝新贷款
  • 对所有新贷款,拒绝高违约概率者
    • 用测试集模拟新贷款
  • 接受率:为降低投资组合违约数,接受的新贷款占比
    • 被接受但实际违约的贷款影响类似假阴性
Python 信用风险建模

理解接受率

  • 示例:接受 prob_default 最低的 85% 贷款

预测概率分布直方图

Python 信用风险建模

计算阈值

  • 计算 85% 接受率对应的阈值
import numpy as np
# Compute the threshold for 85% acceptance rate
threshold = np.quantile(prob_default, 0.85)
0.804
Loan prob_default Threshold Predicted loan_status Accept or Reject
1 0.65 0.804 0 接受
2 0.85 0.804 1 拒绝
Python 信用风险建模

应用计算得到的阈值

  • 用新阈值重新赋值 loan_status
# Compute the quantile on the probabilities of default
preds_df['loan_status'] = preds_df['prob_default'].apply(lambda x: 1 if x > 0.804 else 0)
Python 信用风险建模

坏账率

  • 即使设定了阈值,一些获批贷款仍会违约
  • 这些贷款的 prob_default 位于模型校准不佳的区域附近

以坏账率高亮的已获批贷款柱状图

Python 信用风险建模

坏账率计算

坏账率公式

#Calculate the bad rate
np.sum(accepted_loans['true_loan_status']) / accepted_loans['true_loan_status'].count()
  • 若非违约为 0、违约为 1,则 sum() 即违约笔数
  • 单列的 .count() 等于数据框的行数
Python 信用风险建模

¡Vamos a practicar!

Python 信用风险建模

Preparing Video For Download...