# How do I perform K-Means clustering of the Olivetti Dataset

This Question pertains to Matrix Factorization and the full question is given below. Provide for k-means clustering of the Olivetti dataset the following visualizations:

• A scatter plot of the r = 2-dimensional representation of the faces in the latent space, together with the faces which represent the two dimensions/features.
• A visualization of the faces which define the features of the latent space for r = 5.
• The reconstruction of the faces with indices i ∈ {0, 10, 20} when using a rank of r ∈ {5, 25, 50, 100}

To load the Olivetti Dataset run the following code:

from sklearn.datasets import fetch_olivetti_faces
faces = fetch_olivetti_faces()


And print(faces.DESCR) provides a description of the data set.

When I try to K-Means clustering on the model I receive

**TypeError: float() argument must be a string or a number, not 'Bunch'**


Thank you for your time and consideration

• from sklearn.cluster import KMeans from sklearn import datasets from sklearn.datasets import fetch_olivetti_faces faces = fetch_olivetti_faces() kmeans = KMeans(n_clusters = 50) kmeans.fit(faces) Apr 25, 2020 at 11:03