เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Preprocess

Feature engineering time! You need to build a recipe to take care of non-informative but possibly valuable variables such as observation ID or deal with missing values. This is also an opportunity to transform some predictors. Say, normalize numerical features and create dummy variables for categorical ones.

The attrition dataset and the train and test splits you created in the previous exercise are available in your environment.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Feature Engineering in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Normalize all numeric features.
  • Impute missing values using the knn imputation algorithm.
  • Create dummy variables for all nominal predictors.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

recipe <- recipe(Attrition ~ ., data = train) %>%
  update_role(...1, new_role = "ID") %>%

# Normalize all numeric features
  ___(all_numeric_predictors()) %>% 

# Impute missing values using the knn imputation algorithm
  ___(all_predictors()) %>%

# Create dummy variables for all nominal predictors
  ___(all_nominal_predictors())
 
recipe
แก้ไขและรันโค้ด