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
I have a couple of observations about this:


Before you run clustering, I'd run some dimensionality reduction model. Pixel data are too noisy to be fed as they are into a model. With dimensionality reduction you get both noise reduction and lower computational costs.
Images usually come as 2D or 3D arrays (depending whether they are in grayscale or coloured). On the other side, k-Means and other sklearn models require your whole dataset as a 2D array. You should process each image and turn it into a 1D array that can be fed as a single observation.


Could you share your clustering code, just to make sure?