评估逻辑回归模型结果

R 中的信用风险建模

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

回顾:模型评估

test_set$loan_status    model_prediction   
               ...                 ...
[8066,]          1                   1
[8067,]          0                   0
[8068,]          0                   0
[8069,]          0                   0
[8070,]          0                   0
[8071,]          0                   1
[8072,]          1                   0
[8073,]          1                   1
[8074,]          0                   0
[8075,]          0                   0
[8076,]          0                   0
[8077,]          1                   1
[8078,]          0                   0
[8079,]          0                   1
        ...                        ...

实际贷款状态 vs 模型预测

未违约 (0) 违约 (1)
未违约 (0) 8 2
违约 (1) 1 3
R 中的信用风险建模

现实中…

test_set$loan_status    model_prediction   
               ...                  ....
[8066,]          1            0.09881492
[8067,]          0            0.09497852
[8068,]          0            0.21071984
[8069,]          0            0.04252119
[8070,]          0            0.21110838
[8071,]          0            0.08668856
[8072,]          1            0.11319341
[8073,]          1            0.16662207
[8074,]          0            0.15299176
[8075,]          0            0.08558058
[8076,]          0            0.08280463
[8077,]          1            0.11271048
[8078,]          0            0.08987446
[8079,]          0            0.08561631
         ....                     ....

实际贷款状态 vs 模型预测

未违约 (0) 违约 (1)
未违约 (0) ? ?
违约 (1) ? ?
R 中的信用风险建模

现实中…

test_set$loan_status    model_prediction   
         ....                     ....
[8066,]          1            0.09881492
[8067,]          0            0.09497852
[8068,]          0            0.21071984
[8069,]          0            0.04252119
[8070,]          0            0.21110838
[8071,]          0            0.08668856
[8072,]          1            0.11319341
[8073,]          1            0.16662207
[8074,]          0            0.15299176
[8075,]          0            0.08558058
[8076,]          0            0.08280463
[8077,]          1            0.11271048
[8078,]          0            0.08987446
[8079,]          0            0.08561631
         ....                     ....

截止或阈值

  • 介于 0 和 1 之间
R 中的信用风险建模

Cutoff = 0.5

test_set$loan_status    model_prediction   
         ...                       ...
  [8066,]          1                   0
  [8067,]          0                   0
  [8068,]          0                   0
  [8069,]          0                   0
  [8070,]          0                   0
  [8071,]          0                   0
  [8072,]          1                   0
  [8073,]          1                   0
  [8074,]          0                   0
  [8075,]          0                   0
  [8076,]          0                   0
  [8077,]          1                   0
  [8078,]          0                   0
  [8079,]          0                   0
        ...                        ...
R 中的信用风险建模

Cutoff = 0.5

test_set$loan_status    model_prediction   
         ...                       ...
  [8066,]          1                   0
  [8067,]          0                   0
  [8068,]          0                   0
  [8069,]          0                   0
  [8070,]          0                   0
  [8071,]          0                   0
  [8072,]          1                   0
  [8073,]          1                   0
  [8074,]          0                   0
  [8075,]          0                   0
  [8076,]          0                   0
  [8077,]          1                   0
  [8078,]          0                   0
  [8079,]          0                   0
        ...                        ...

实际贷款状态 vs 模型预测

未违约 (0) 违约 (1)
未违约 (0) 10 0
违约 (1) 4 0

$$

$\text{敏感度} = 0/(4+0) = 0\%$

$\text{准确率} = 10/(10+4+0+0) = 71.4\%$

R 中的信用风险建模

Cutoff = 0.1

test_set$loan_status    model_prediction   
         ...                       ...
  [8066,]          1                   0
  [8067,]          0                   0
  [8068,]          0                   0
  [8069,]          0                   0
  [8070,]          0                   0
  [8071,]          0                   0
  [8072,]          1                   0
  [8073,]          1                   0
  [8074,]          0                   0
  [8075,]          0                   0
  [8076,]          0                   0
  [8077,]          1                   0
  [8078,]          0                   0
  [8079,]          0                   0
        ...                        ...

实际贷款状态 vs 模型预测

未违约 (0) 违约 (1)
未违约 (0) 7 3
违约 (1) 1 3

$$

$\text{敏感度} = 3/(3+1) = 75\%$

$\text{准确率} = 10/(10+4+0+0) = 71.4\%$

R 中的信用风险建模

Vamos praticar!

R 中的信用风险建模

Preparing Video For Download...