Implement the EM algorithm for fitting a Gaussian mixture model for the MNIST dataset… 1 answer below »

Implement the EM algorithm for fitting a Gaussian mixture model for the MNIST dataset. We reduce the dataset to be only two cases, of digits "2" and "6" only. Thus, you will fit GMM with C = 2. Use the data fi le data.mat. True label of the data are also provided in label.mat. The matrix images is of size 784-by-1990, i.e., there are totally 1990 images, and each column of the matrix corresponds to one image of size 28-by-28 pixels (the image is vectorized; the original imagecan be recovered by map the vector into a matrix.)
(a) (5 points) Select from data one raw image of "2" and "6" and visualize them, respectively.
(b) (15 points) Use random Gaussian vector with zero mean as random initial means, and two identitymatrices "I" as initial covariance matrices for the clusters. Plot the log-likelihood function versus the number of iterations to show your algorithm is converging.
(c) (15 points) Report, the fi tting GMM model when EM has terminated in your algorithms,including the weights for each component and the mean vectors (please reformat the vectors into28-by-28 images and show these images in your submission). Ideally, you should be able to see these means corresponds to "average" images. No need to report the covariance matrices.
(d) (15 points) Use the pic to infer the labels of the images, and compare with the true labels. Reportthe miss classi ification rate for digits "2" and "6" respectively. Perform K-means clustering with K = 2 (you may call a package). Find out the miss classifi cation rate for digits "2" and "6" respectively, and compare with GMM. Which one achieves the better performance?
I need the python code for each question asked


Looking for a Similar Assignment? Let us take care of your classwork while you enjoy your free time! All papers are written from scratch and are 100% Original. Try us today!