Machine Learning
Introduction
In this exercise, you will implement the K-means clustering algorithm and apply it to compress an image. In the second part, you will use principal component analysis to find a low-dimensional representation of face images. Before starting on the programming exercise, we strongly recommend watching the video lectures and completing the review questions for the associated topics. To get started with the exercise, you will need to download the starter code and unzip its contents to the directory where you wish to complete the exercise. If needed, use the cd command in Octave to change to this directory before starting this exercise.
Files included in this exercise ex7.m - Octave/Matlab script for the first exercise on K-means ex7 pca.m - Octave/Matlab script for the second exercise on PCA ex7data1.mat - Example Dataset for PCA ex7data2.mat - Example Dataset for K-means ex7faces.mat - Faces Dataset bird small.png - Example Image displayData.m - Displays 2D data stored in a matrix drawLine.m - Draws a line over an exsiting figure plotDataPoints.m - Initialization for K-means centroids plotProgresskMeans.m - Plots each step of K-means as it proceeds runkMeans.m - Runs the K-means algorithm [ ] pca.m - Perform principal component analysis 1
[ [ [ [ [
] ] ] ] ]
projectData.m - Projects a data set into a lower dimensional space recoverData.m - Recovers the original data from the projection findClosestCentroids.m - Find closest centroids (used in K-means) computeCentroids.m - Compute centroid means (used in K-means) kMeansInitCentroids.m - Initialization for K-means centroids
indicates files you will need to complete Throughout the first part of the exercise, you will be using the script ex7.m, for the second part you will use ex7 pca.m. These scripts set up the dataset for the problems and make calls to functions that you will write. You are only