Valutare il risultato della regressione logistica

Credit Risk Modeling in R

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

Riepilogo: valutazione del modello

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
        ...                        ...

Stato reale del prestito vs Predizione del modello

Nessun default (0) Default (1)
Nessun default (0) 8 2
Default (1) 1 3
Credit Risk Modeling in R

Nella pratica...

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
         ....                     ....

Stato reale del prestito vs Predizione del modello

Nessun default (0) Default (1)
Nessun default (0) ? ?
Default (1) ? ?
Credit Risk Modeling in R

Nella pratica...

test_set$loan_status    model_prediction   
         ....                     ....
[8066,]          1            0.09881492
[8077,]          1            0.11271048
[8078,]          0            0.08987446
[8079,]          0            0.08561631
         ....                     ....

Valore di cutoff o soglia

  • Tra 0 e 1
Credit Risk Modeling in 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
        ...                        ...
Credit Risk Modeling in 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
        ...                        ...

Stato reale del prestito vs Predizione del modello

Nessun default (0) Default (1)
Nessun default (0) 10 0
Default (1) 4 0

$$

$\text{Sensibilità} = 0/(4+0) = 0\%$

$\text{Accuratezza} = 10/(10+4+0+0) = 71{,}4\%$

Credit Risk Modeling in 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
        ...                        ...

Stato reale del prestito vs Predizione del modello

Nessun default (0) Default (1)
Nessun default (0) 7 3
Default (1) 1 3

$$

$\text{Sensibilità} = 3/(3+1) = 75\%$

$\text{Accuratezza} = 10/(10+4+0+0) = 71{,}4\%$

Credit Risk Modeling in R

Ayo berlatih!

Credit Risk Modeling in R

Preparing Video For Download...