เตรียม Recipe ให้พร้อม
ในแบบฝึกหัดนี้ จะสำรวจชุดข้อมูล attrition_num จากมุมมองของ PCA เพื่อดูว่าสามารถลดมิติข้อมูลได้จริงหรือไม่ โดยยังคงรักษาข้อมูลส่วนใหญ่ไว้ เริ่มต้นด้วยการสร้าง recipe ที่กรอง features ที่มี near-zero variance ออก จากนั้น normalize ข้อมูล และนำ PCA ไปใช้
ชุดข้อมูล attrition_num ถูกโหลดไว้ให้แล้ว
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Feature Engineering in R
คำแนะนำการฝึกหัด
- ลบ features ที่อาจมี near-zero variance ออก
- Normalize ข้อมูลตัวเลขทั้งหมด
- นำ PCA ไปใช้
- เข้าถึงชื่อของ output elements โดยการ prepare recipe
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
pc_recipe <- recipe(~., data = attrition_num) %>%
# Remove possible near-zero variance features
___(all_numeric()) %>%
# Normalize all numeric data
___(___()) %>%
# Apply PCA
___(all_numeric())
# Access the names of the output elements by preparing the recipe
pca_output <- ___(___)
names(pca_output)