바이어스-분산 트레이드오프

R로 배우는 트리 기반 Machine Learning

Sandro Raabe

Data Scientist

하이퍼파라미터

  • 모델러가 선택
  • 예: tree_depth
  • 문서 확인!
?decision_tree

여러 하이퍼파라미터

R로 배우는 트리 기반 Machine Learning

단순 모델

simple_spec <- decision_tree(tree_depth = 2) %>% 
    set_mode("regression")

simple_spec %>% fit(final_grade ~ .,
                    data = training_data)

복잡한 모델

complex_spec <- decision_tree(tree_depth = 15) %>% 
    set_mode("regression")

complex_spec %>% fit(final_grade ~ .,
                     data = training_data)

깊이 2 트리

깊이 30 트리

R로 배우는 트리 기반 Machine Learning

복잡한 모델 - 오버피팅 - 높은 분산

학습 세트 예측: 잘 맞음

학습 세트의 작은 오류

mae(train_results, 
    estimate = .pred,
    truth = final_grade)
# A tibble: 1 x 3
  .metric  .estimate
1 mae          0.204

테스트 세트 예측: 크게 빗나감!

테스트 세트의 큰 오류

mae(test_results, 
    estimate = .pred,
    truth = final_grade)
# A tibble: 1 x 3
  .metric  .estimate
1 mae          0.947
R로 배우는 트리 기반 Machine Learning

단순 모델 - 언더피팅 - 높은 바이어스

학습과 테스트에서 모두 오류:

bind_rows(training = mae(train_results, estimate = .pred, truth = final_grade),
          test     = mae(test_results,  estimate = .pred, truth = final_grade),
          .id = "dataset")
# A tibble: 2 x 4
  dataset    .metric  .estimate
  <chr>      <chr>        <dbl>
1 training   mae          0.754
2 test       mae          0.844
R로 배우는 트리 기반 Machine Learning

바이어스-분산 트레이드오프

바이어스-분산 트레이드오프

 

  • 단순 모델 -> 바이어스 큼
  • 복잡한 모델 -> 분산 큼
  • 바이어스와 분산의 균형
  • 적정점에 맞춰 모델 구성
R로 배우는 트리 기반 Machine Learning

오버피팅 감지

오프샘플/CV:

collect_metrics(cv_fits)


# A tibble: 1 x 3
  .metric    mean     n 
1 mae       2.432     5
  • CV 오류 큼
  • 오버피팅 / 높은 분산
  • 복잡도 줄이기!

인샘플:

mae(training_pred, 
    estimate = .pred, 
    truth = final_grade)
# A tibble: 1 x 2
  .metric  .estimate
1 mae          0.228
  • 학습 오류 작음
R로 배우는 트리 기반 Machine Learning

언더피팅 감지

인샘플:

mae(training_pred, estimate = .pred, truth = final_grade)
# A tibble: 1 x 2
  .metric .estimate
  <chr>       <dbl>
1 mae         2.432
  • 인샘플/학습 오류 큼
  • 언더피팅 / 높은 바이어스
  • 복잡도 늘리기!
R로 배우는 트리 기반 Machine Learning

트레이드오프 해봅시다!

R로 배우는 트리 기반 Machine Learning

Preparing Video For Download...