Analyzing principal components
Principal components are constructed as linear combinations of original variables, which makes them less interpretable and devoid of inherent meaning. This means that after implementing PCA, we need to determine the meaning of the components. One approach to do this is analyzing the relationship between the original variables and the principal components. The values that express this relationship are called loadings.
We will explore how to analyze principal components using sklearn
.
Getting ready
We will work with the Customer Personality Analysis data from Kaggle on this recipe. You can retrieve all the files from the GitHub repository.
How to do it…
We will learn how to analyze the output of a PCA model using the sklearn
library:
- Import the
pandas
,matplotlib
,seaborn
, andsklearn
libraries:import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from sklearn.preprocessing import StandardScaler from sklearn...