Wie blijft er?
Tijd om meerdere transformaties te combineren op de gegevens in attrition_num. Normaliseer of maak numerieke variabelen eerst bijna-normaal met een Yeo-Johnson-transformatie. Zet daarna numerieke voorspellers om naar percentielen, maak dummyvariabelen en verwijder features met een (bijna) nulvariantie.
Deze oefening maakt deel uit van de cursus
Feature engineering in R
Oefeninstructies
- Pas een Yeo-Johnson-transformatie toe op alle numerieke variabelen.
- Zet alle numerieke voorspellers om naar percentielen.
- Maak dummyvariabelen voor alle nominale voorspellers.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
lr_recipe <- recipe(Attrition ~., data = train) %>%
# Apply a Yeo-Johnson transformation to all numeric variables
___ %>%
# Transform all numeric predictors into percentiles
___ %>%
# Create dummy variables for all nominal predictors
___
lr_workflow <- workflow() %>% add_model(lr_model) %>% add_recipe(lr_recipe)
lr_fit <- lr_workflow %>% fit(train)
lr_aug <- lr_fit %>% augment(test)
lr_aug %>% class_evaluate(truth = Attrition, estimate = .pred_class,.pred_No)