모델 일반화: 부트스트래핑과 교차 검증

Python으로 연습하는 Machine Learning 면접 질문

Lisa Stuart

Data Scientist

4장 개요

  • 부트스트래핑/교차 검증 → 모델 일반화
  • 클래스 불균형
  • 상관된 특성
  • 앙상블 모델 선택
Python으로 연습하는 Machine Learning 면접 질문

모델 일반화

  • 보지 못한 데이터에서도 잘 수행하는 ML 모델의 능력
    • 테스트 데이터셋
    • 미래 데이터
  • 학습 지표 ≈ 테스트 지표
  • 과적합 모델은 일반화하지 못함
Python으로 연습하는 Machine Learning 면접 질문

의사결정나무

의사결정나무 플롯

1 https://medium.com/@rnbrown/creating-and-visualizing-decision-trees-with-python-f8e8fa394176
Python으로 연습하는 Machine Learning 면접 질문

의사결정나무 노드

의사결정나무 루트 노드

Python으로 연습하는 Machine Learning 면접 질문

장점 vs 단점

의사결정나무 플롯

  • 장점:
    • 이해하기 쉬움
    • 시각화 용이
  • 단점:
    • 과적합 쉬움
    • 탐욕적 방식으로 간주됨
    • 클래스 불균형에 편향됨
Python으로 연습하는 Machine Learning 면접 질문

랜덤 포레스트

랜덤 포레스트

1 https://www.researchgate.net/figure/Random-Forest-visualization_fig11_326560291
Python으로 연습하는 Machine Learning 면접 질문

K-겹 교차 검증

K-겹 교차 검증

1 https://scikit-learn.org/stable/modules/cross_validation.html
Python으로 연습하는 Machine Learning 면접 질문

함수

# decision tree
`sklearn.tree.DecisionTreeClassifier` 

# random forest 
`sklearn.ensemble.RandomForestClassifier`

# cross-validated grid search
`sklearn.model_selection.GridSearchCV` 

# model accuracy
`sklearn.metrics.accuracy_score` 

# train/test split function
`sklearn.model_selection.train_test_split`

# Parameters that gave best results
`cross-val_model.best_params_`

# Mean cross-validated score of 
# estimator with best params 
`cross-val_model.best_score_`
Python으로 연습하는 Machine Learning 면접 질문

GridSearchCV vs RandomSearchCV

그리드 서치

Python으로 연습하는 Machine Learning 면접 질문

연습해 봅시다!

Python으로 연습하는 Machine Learning 면접 질문

Preparing Video For Download...