step_poly()
이제 기준 모델이 준비되었으니, 모든 숫자형 값에 다항식 변환을 추가했을 때의 성능을 비교해 보세요.
attrition_num 데이터, 로지스틱 회귀 lr_model, 사용자 정의 함수 class-evaluate(), 그리고 train 및 test 분할은 이미 로드되어 있어요.
이 연습은 강의의 일부입니다
R로 배우는 Feature Engineering
연습 안내
- 모든 숫자형 예측 변수에 다항식 변환을 추가하세요.
- 워크플로를 학습용 데이터에 적합(fit)하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
lr_recipe_poly <-
recipe(Attrition ~., data = train) %>%
# Add a polynomial transformation to all numeric predictors
___
lr_workflow_poly <- workflow() %>%
add_model(lr_model) %>%
add_recipe(lr_recipe_poly)
# Fit workflow to the train data
lr_fit_poly <- ___ %>% fit(train)
lr_aug_poly <- lr_fit_poly %>% augment(test)
lr_aug_poly %>% class_evaluate(truth = Attrition, estimate = .pred_class,.pred_No)