Variance explained
The second common plot type for understanding PCA models is a scree plot. A scree plot shows the variance explained as the number of principal components increases. Sometimes the cumulative variance explained is plotted as well.
In this and the next exercise, you will prepare data from the pr.out model you created at the beginning of the chapter for use in a scree plot. Preparing the data for plotting is required because there is not a built-in function in R to create this type of plot.
이 연습은 강의의 일부입니다
Unsupervised Learning in R
연습 안내
pr.out and the pokemon data are still available in your workspace.
- Assign to the variable
pr.varthe square of the standard deviations of the principal components (i.e., the variance). The standard deviation of the principal components is available in thesdevcomponent of the PCA model object. - Assign to the variable
pvethe proportion of the variance explained, calculated by dividingpr.varby the total variance explained by all principal components.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Variability of each principal component: pr.var
pr.var <- ___
# Variance explained by each principal component: pve
pve <- ___ / ___