행렬로 들어가기
EducationField에서 서로 다른 값 6개를 확인하셨습니다. 하지만 모델을 새 데이터에 적용할 때 다른 값이 나타날 수도 있다고 의심하십니다. 이를 대비해 50개의 용어(term)를 가진 해시 인덱스를 만들겠습니다. textrecipes 패키지와 attrition_train, attrition_test 분할은 이미 로드되어 있습니다.
이 연습은 강의의 일부입니다
R로 배우는 Feature Engineering
연습 안내
- 레시피에
EducationField에 대한 dummy_hash 인덱스를 생성하는 단계를 추가하세요. - 레시피를 준비(prep)하세요.
- 준비된 레시피를 베이크(bake)하세요.
- 베이크된 레시피 테이블과
EducationField값을 하나의 테이블로 바인딩한 다음, 처음 7개 행과 1번 열 및 18~20번 열을 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
recipe <- recipe(~EducationField, data = attrition_train) %>%
# Add a step to the recipe that generates a dummy_hash index for EducationField
___(EducationField, prefix = NULL, signed = FALSE, num_terms = 50L)
# Prepare the recipe
object <- recipe %>%
___
# Bake the prepped recipe
baked <- ___(object, new_data = attrition_test)
# Bind the baked recipe table and the EducationField values into one table
bind_cols(___, baked)[1:7,c(1,18:20)]