信贷策略与最小期望损失

Python 信用风险建模

Michael Crabtree

Data Scientist, Ford Motor Company

选择接受率

  • 初始接受率设为 85%,也可选择其他比例
  • 测试不同接受率的两种方式:
    • 手动计算阈值、不良率和损失
    • 自动生成这些值的表,并据此选择接受率
  • 所有可能取值的表称为策略表(strategy table)
Python 信用风险建模

建立策略表

  • 设置数组或列表以存储各项数值
# Set all the acceptance rates to test
accept_rates = [1.0, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55,
                0.5, 0.45, 0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05]
# Create lists to store thresholds and bad rates 
thresholds = []
bad_rates = []
Python 信用风险建模

计算表中数值

  • 为所有接受率计算阈值和不良率
for rate in accept_rates:
    # Calculate threshold
    threshold = np.quantile(preds_df['prob_default'], rate).round(3)
    # Store threshold value in a list
    thresholds.append(np.quantile(preds_gbt['prob_default'], rate).round(3))
    # Apply the threshold to reassign loan_status
    test_pred_df['pred_loan_status'] = \ 
        test_pred_df['prob_default'].apply(lambda x: 1 if x > thresh else 0)
    # Create accepted loans set of predicted non-defaults
    accepted_loans = test_pred_df[test_pred_df['pred_loan_status'] == 0]
    # Calculate and store bad rate
    bad_rates.append(np.sum((accepted_loans['true_loan_status']) 
             / accepted_loans['true_loan_status'].count()).round(3))
Python 信用风险建模

解读策略表

strat_df = pd.DataFrame(zip(accept_rates, thresholds, bad_rates),
                        columns = ['Acceptance Rate','Threshold','Bad Rate'])

策略表与不良率条形图示例

Python 信用风险建模

加入已接受的贷款数

  • 各接受率下被接受的贷款数量
    • 可用 len().count()

含已接受贷款数的策略表

Python 信用风险建模

加入平均贷款金额

  • 测试集中的平均 loan_amnt

含平均贷款金额的策略表

Python 信用风险建模

估算组合价值

  • 已接受的非违约平均值减去已接受的违约平均值
  • 假设每次违约损失为 loan_amnt

含估计价值的策略表

Python 信用风险建模

总期望损失

  • 组合中违约导致的预期损失

总期望损失公式

# Probability of default (PD)
test_pred_df['prob_default']
# Exposure at default = loan amount (EAD)
test_pred_df['loan_amnt']
# Loss given default = 1.0 for total loss (LGD)
test_pred_df['loss_given_default']
Python 信用风险建模

Passons à la pratique !

Python 信用风险建模

Preparing Video For Download...