모델 적합과 성능 평가
이제 결측값을 처리하고 더미 변수를 만들었으니, 모델의 성능을 평가해 볼 차례예요!
attrition 데이터세트와 test 및 train 분할, lr_recipe, 그리고 미리 선언된 logistic_model()이 이미 로드되어 있어요.
이 연습은 강의의 일부입니다
R로 배우는 Feature Engineering
연습 안내
- 모델과 레시피를 워크플로로 묶으세요.
- 워크플로를 학습용 데이터에 적합하세요.
- 성능 평가를 위해 보강된(augmented) 데이터 프레임을 생성하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Bundle model and recipe in workflow
lr_workflow <- ___() %>%
add_model(lr_model) %>%
add_recipe(lr_recipe)
# Fit workflow to the train data
lr_fit <- ___(lr_workflow, data = train)
# Generate an augmented data frame for performance assessment
lr_aug <- lr_fit %>% ___(test)
lr_aug %>% roc_curve(truth = Attrition, .pred_No) %>% autoplot()
bind_rows(lr_aug %>% roc_auc(truth = Attrition, .pred_No),
lr_aug %>% accuracy(truth = Attrition, .pred_class))