總結與重點說明

R 的信用風險建模

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

哪個 cut-off 能讓準確率最佳?

$$

Screen Shot 2020-06-22 at 2.42.06 PM.png

$$

$\text{Accuracy} = \frac{TP + TN}{TP + FP + TN + FN}$

R 的信用風險建模

哪個 cut-off 能讓準確率最佳?

$$

Screen Shot 2020-06-22 at 2.42.20 PM.png

$$

$\text{Accuracy} = \frac{TP + TN}{TP + FP + TN + FN}$

R 的信用風險建模

哪個 cut-off 能讓準確率最佳?

$$

Screen Shot 2020-06-22 at 2.42.36 PM.png

$$

$\text{Accuracy} = \frac{TP + TN}{TP + FP + TN + FN}$

R 的信用風險建模

哪個 cut-off 能讓準確率最佳?

$$

Screen Shot 2020-06-22 at 2.42.50 PM.png

$$

$\text{Accuracy} = \frac{TP + TN}{TP + FP + TN + FN}$

R 的信用風險建模

哪個 cut-off 能讓準確率最佳?

$$

Screen Shot 2020-06-22 at 2.42.50 PM.png

$$

$\text{Accuracy} = 89.31\%$

$\text{Actual defaults in test set} = 10.69\%$

$$ = (100 - 89.31)\%$$

R 的信用風險建模

那靈敏度與特異度呢?

$$

Screen Shot 2020-06-22 at 2.43.10 PM.png

$$

$\text{Sensitivity} = 1037 / (1037 + 0) = 100\%$

$\text{Specificity} = 0 / (0 + 864) = 0\%$

R 的信用風險建模

那靈敏度與特異度呢?

$$

Screen Shot 2020-06-22 at 2.43.24 PM.png

R 的信用風險建模

那靈敏度與特異度呢?

$$

Screen Shot 2020-06-22 at 2.43.39 PM.png

$$

$\text{Sensitivity} = 0 / (0 + 1037) = 0\%$

$\text{Specificity} = 8640 / (8640 + 0) = 100\%$

R 的信用風險建模

關於羅吉斯迴歸…

log_model_full <- glm(loan_status ~ ., family = "binomial", data = training_set)

與下列寫法相同:

log_model_full <- glm(loan_status ~ ., family = binomial(link = logit), data = training_set)

回顧:

$$P({\text{loan status}}=1|x_1,...,x_m) = \frac{1}{1+e^{-(\beta_0 + \beta_1 x_1 + ... + \beta_m x_m)}}$$

R 的信用風險建模
log_model_full <- glm(loan_status ~ ., 
                      family = binomial(link = probit), 
                      data = training_set)

log_model_full <- glm(loan_status ~ ., 
                      family = binomial(link = cloglog), 
                      data = training_set)
  • $\beta_j < 0$
    • 當 $x_j$ 增加,違約機率會下降
  • $\beta_j > 0$
    • 當 $x_j$ 增加,違約機率會上升

$$P({\text{loan status}}=1|x_1,...,x_m) = \frac{1}{1+e^{-(\beta_0 + \beta_1 x_1 + ... + \beta_m x_m)}}$$

R 的信用風險建模

一起來練習吧!

R 的信用風險建模

Preparing Video For Download...