추가 모델 지표

R로 배우는 트리 기반 Machine Learning

Sandro Raabe

Data Scientist

정확도의 한계

 

  • no만 항상 예측하는 "나이브" 모델도 정확도 98% 가능

→ 음성 98%의 불균형 데이터셋에서 발생 가능

R로 배우는 트리 기반 Machine Learning

민감도(참양성률)

  • 전체 양성 중 올바르게 분류한 비율

민감도를 보여주는 혼동 행렬

R로 배우는 트리 기반 Machine Learning

특이도(참음성률)

  • 전체 음성 중 올바르게 분류한 비율

특이도를 보여주는 혼동 행렬

R로 배우는 트리 기반 Machine Learning

서로 다른 임곗값 테이블

R로 배우는 트리 기반 Machine Learning

ROC(수신자 조작 특성) 곡선

  • 모든 가능한 임곗값에서 분류 모델의 성능을 시각화

ROC 곡선 플롯

R로 배우는 트리 기반 Machine Learning

ROC 곡선과 AUC

다양한 ROC 곡선

R로 배우는 트리 기반 Machine Learning

ROC 곡선 아래 면적(AUC)

AUC 플롯

  • AUC = 0.5
  • 무작위와 동등한 성능

 

  • AUC = 1
  • 모든 임곗값에서 전부 정분류 → 완벽한 모델

 

  • AUC = 0
  • 모든 사례를 오분류
R로 배우는 트리 기반 Machine Learning

yardstick 민감도: sens()

predictions
# A tibble: 153 x 2
.pred_class   true_class
      <fct>        <fct>     
 1      yes           no        
 2       no           no        
 3       no          yes       
 4      yes          yes
# 단일 임곗값에서 민감도 계산
sens(predictions, 
     estimate = .pred_class, 
     truth = true_class)
# A tibble: 1 x 2
  .metric        .estimate
  <chr>              <dbl>
1 sensitivity        0.872
  • accuracy(), conf_mat()와 유사한 인수
R로 배우는 트리 기반 Machine Learning

yardstick ROC: roc_curve()

# 테스트셋에서 확률 예측
predictions <- predict(model,
                       data_test,

type = "prob") %>%
bind_cols(data_test)
# A tibble: 9,116 x 13
   .pred_yes still_customer age gender    ...
       <dbl> <fct>         <int> <fct>    ...
 1    0.0557 no               45 M        ...
 2    0.0625 no               49 F        ...
 3    0.330  no               51 M        ...
 4    ...
 ...
# 모든 임곗값에 대한 ROC 곡선 계산
roc <- roc_curve(predictions,

estimate = .pred_yes,
truth = still_customer)
# ROC 곡선 그리기 autoplot(roc)

roc 곡선

R로 배우는 트리 기반 Machine Learning

yardstick AUC: roc_auc()

  • 동일한 인수: 데이터, 예측 열, 정답 열
# 곡선 아래 면적 계산
roc_auc(predictions, 
        estimate = .pred_yes, 
        truth = still_customer)
# A tibble: 1 x 3
  .metric .estimator .estimate
  <chr>   <chr>          <dbl>
1 roc_auc binary         0.872
R로 배우는 트리 기반 Machine Learning

측정해 봅시다!

R로 배우는 트리 기반 Machine Learning

Preparing Video For Download...