LoslegenKostenlos loslegen

Percent of variance explained

From the pca_output, you can retrieve the standard deviation explained by each principal component. Then, use these values to compute the variance explained and the cumulative variance explained, and glue together these values into a tibble.

The pca_output object is loaded for you.

Diese Übung ist Teil des Kurses

Feature Engineering in R

Kurs anzeigen

Anleitung zur Übung

  • Calculate percentage of variance explained leveraging the standard deviation vector.
  • Create a tibble with principal components, variance explained and cumulative variance explained.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

sdev <- pca_output$steps[[3]]$res$sdev
# Calculate percentage of variance explained
var_explained <- ___

# Create a tibble with principal components, variance explained and cumulative variance explained
PCA = tibble(PC = 1:length(sdev), var_explained = ___, 
       cumulative = ___) 
Code bearbeiten und ausführen