BaşlayınÜcretsiz Başlayın

Imputing missing values and creating dummy variables

After detecting missing values in the attrition dataset and determining that they are missing completely at random (MCAR), you decide to use K Nearest Neighbors (KNN) imputation. While configuring your feature engineering recipe, you decide to create dummy variables for all your nominal variables and update the role of the ...1 variable to "ID" so you can keep it in the dataset for reference, without affecting your model.

Bu egzersiz

Feature Engineering in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Update the role of ...1 to "ID".
  • Impute values to all predictors where data are missing.
  • Create dummy variables for all nominal predictors.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

lr_model <- logistic_reg()

lr_recipe <- 
  recipe(Attrition ~., data = train) %>%

# Update the role of "...1" to "ID"
  ___(...1, new_role = "ID" ) %>%

# Impute values to all predictors where data are missing
  step_impute_knn(___) %>%

# Create dummy variables for all nominal predictors
  ___(all_nominal_predictors())

lr_recipe
Kodu Düzenle ve Çalıştır