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

Visualizing variance explained

With all the calculations under your belt, it always comes in handy to represent our data visually. You will now create a column plot showing variance explained by principal component.

The variable_explained vector you created in the last exercise is available, and the ggplot() theme_() is set to classic.

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

Feature Engineering in R

ดูคอร์ส

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

  • Use the information in the PCA tibble to create a column plot of variance explained.

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

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

PCA = tibble(PC = 1:length(sdev), var_explained = var_explained, 
       cumulative = cumsum(var_explained))

# Use the information in the PCA tibble to create a column plot of variance explained
PCA %>% ggplot(aes(x = ___, y = ___)) +
  geom_col(fill = "steelblue") +
  xlab("Principal components") +
  ylab("Variance explained")
แก้ไขและรันโค้ด