First Principle Component
First load the data and store in pandas dataframe.the dataset contains country and foods. It based on average weekly consumption, per person and in grams. The standardize data transfer to unit scale. The mean value is 0 and variance is 1.The null value also converted to 0.Because the PCA only applied numerical data.
The covariance matrix
- There are two p[principle components used to implement the covariance matrix. The most variance in the original values capture by the first principle component. The second variance contains dataset and it represents the second principle component.Consider, PC1 and PC2.PC1 is first principle component and PC2 second principle component. The first principle component denoted the direction between two features and second component denoted the direction between two plotted features. We have seventeen types of food and plot the graph based on the food and country.
- The England dataset value change from current value. The values are 300, 40, 225, 500, 100, 50, 110, 93, 1100,800, 300, 650, 330, 500, 100, 1200, 180.It change the singular value and covariance matrix.
Value
Graph
4.The original value dataset graph
First plot the pair of lines. It based on x values and y values. The PCA useful for eliminating dimensions.
Apply the first principle component for original dataset.
The second graph based on PCA. It make the one dimension and the principle component with most variation.