PRACTICAL 14: PRINCIPAL COMPONENT ANALYSIS (PCA)

(The PCA code with the explained-variance plot is given in Practical 7: 4. PCA.)

STEPS:
1. Standardize the data: make every feature have mean 0 and standard deviation 1.
2. Calculate the covariance matrix to see how the features vary together.
3. Find the principal components: the eigenvectors (directions) and eigenvalues (importance) of the covariance matrix.
4. Pick the top k components that keep most of the variance (for example 95%) and transform the data by projecting it on them.

EXPLANATION:
- PCA is a dimensionality reduction technique that reduces the number of features while keeping the most important information.
- It converts correlated features into a smaller set of uncorrelated features called principal components.
- PC1 is the direction of maximum variance and PC2 is the next best direction, perpendicular to PC1.
- Example: with the two features Radius and Area, most of the spread lies along PC1, so projecting on PC1 turns 2D data into 1D with little loss.
- The explained variance ratio tells how much information each component keeps.
