R로 배우는 신용 위험 모델링
Lore Dirick
Manager of Data Science Curriculum at Flatiron School



1) 모든 변수(본 예: 7개)를 포함한 모델로 시작해 AUC 계산
log_model_full <- glm(loan_status ~ loan_amnt + grade + home_ownership +
annual_inc + age + emp_cat + ir_cat,
family = "binomial", data = training_set)
predictions_model_full <- predict(log_model_full,
newdata = test_set, type ="response")
AUC_model_full <- auc(test_set$loan_status, predictions_model_full)
Area under the curve: 0.6512
2) 각 변수를 하나씩 제거한 7개 모델을 만들고, 테스트 세트로 PD 예측 수행
log_1_remove_amnt <- glm(loan_status ~ grade + home_ownership + annual_inc + age + emp_cat + ir_cat,
family = "binomial",
data = training_set)
log_1_remove_grade <- glm(loan_status ~ loan_amnt + home_ownership + annual_inc + age + emp_cat + ir_cat,
family = "binomial",
data = training_set)
log_1_remove_home <- glm(loan_status ~ loan_amnt + grade + annual_inc + age + emp_cat + ir_cat,
family = "binomial",
data = training_set)
pred_1_remove_amnt <- predict(log_1_remove_amnt, newdata = test_set, type = "response")
pred_1_remove_grade <- predict(log_1_remove_grade, newdata = test_set, type = "response")
pred_1_remove_home <- predict(log_1_remove_home, newdata = test_set, type = "response")
...
3) 최상의 AUC를 낸 모델 유지 (전체 모델 AUC: 0.6512)
auc(test_set$loan_status, pred_1_remove_amnt)
Area under the curve: 0.6537
auc(test_set$loan_status, pred_1_remove_grade)
Area under the curve: 0.6438
auc(test_set$loan_status, pred_1_remove_home)
Area under the curve: 0.6537
4) AUC가 (유의하게) 감소할 때까지 반복
R로 배우는 신용 위험 모델링