Description
1 Covariance Matrix (25 points)
Implement: You will implement the following function
def compute_covariance_matrix(Z)
The above function will take the data matrix Z and return the covariance matrix Z
TZ=COV (a numpy array).
2 PCS (25 points)
Implement: You will implement the following function
def find_pcs(cov)
The above function will take the covariance matrix cov and return the ordered (largest to smallest) principal
components PCS (a numpy array where each column is an eigenvector) and corresponding eigenvalues L (a
numpy array). You will want to use np.linalg.eig for this.
3 Project Data (25 points)
Implement: You will implement the following function
def project_data(Z, PCS, L)
The above function will take the data matrix Z, the principal components PCS, and corresponding eigenvalues
L. We expect you to maintain 1 principal component (project all the data onto a single axis). This function
will return Z_star, the projected data.
4 Plotting (25 points)
Implement: You will implement the following function
def show_plot(Z, Z_star)
The above function will take the original data Z, and the projected data Z_star. On the same figure, plot
the original data Z as a scatter plot, and the projected data Z_star as a line. Save this data into an image
file (.jpg preferred) and turn it in with the report. For the report give a brief explanation of the benefit to
principal component analysis when dealing with higher dimensional feature vectors.
1