기본 레시피
퇴사한 직원에 대한 모든 숫자형 데이터가 담긴 attrition_num 데이터셋을 사용해, factor로 코딩된 이진 변수 Attrition을 타깃으로 직원이 계속 근무할 가능성을 예측하는 모델을 만들고자 합니다. 시작을 위해, 모델 수식과 학습 데이터를 정의하는 것 외에는 아무 작업도 하지 않는 기본 레시피를 정의해 보겠습니다.
attrition_num 데이터, 로지스틱 회귀 lr_model, 사용자 정의 함수 class-evaluate(), 그리고 train과 test 분할은 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
R로 배우는 Feature Engineering
연습 안내
- 모델 수식만 정의하는 기본 레시피를 생성하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create a plain recipe defining only the model formula
lr_recipe_plain <-
___(___ ~., ___ = ___)
lr_workflow_plain <- workflow() %>%
add_model(lr_model) %>%
add_recipe(lr_recipe_plain)
lr_fit_plain <- lr_workflow_plain %>%
fit(train)
lr_aug_plain <-
lr_fit_plain %>% augment(test)
lr_aug_plain %>% class_evaluate(truth = Attrition,
estimate = .pred_class,.pred_No)