nents extracted (figure - )as well as reconstructions of faces from the test set using components (figure - for -meansthe reconstruction is the closest cluster center found on the training setin[ ]x_trainx_testy_trainy_test train_test_splitx_peopley_peoplestratify=y_peoplerandom_state= nmf nmf(n_components= random_state= nmf fit(x_trainpca pca(n_components= random_state= pca fit(x_trainkmeans kmeans(n_clusters= random_state= kmeans fit(x_trainx_reconstructed_pca pca inverse_transform(pca transform(x_test)x_reconstructed_kmeans kmeans cluster_centers_[kmeans predict(x_test)x_reconstructed_nmf np dot(nmf transform(x_test)nmf components_in[ ]figaxes plt subplots( figsize=( )subplot_kw={'xticks'()'yticks'()}fig suptitle("extracted components"for axcomp_kmeanscomp_pcacomp_nmf in zipaxes tkmeans cluster_centers_pca components_nmf components_)ax[ imshow(comp_kmeans reshape(image_shape)ax[ imshow(comp_pca reshape(image_shape)cmap='viridis'ax[ imshow(comp_nmf reshape(image_shape)axes[ set_ylabel("kmeans"axes[ set_ylabel("pca"axes[ set_ylabel("nmf"figaxes plt subplots( subplot_kw={'xticks'()'yticks'()}figsize=( )fig suptitle("reconstructions"for axorigrec_kmeansrec_pcarec_nmf in zipaxes tx_testx_reconstructed_kmeansx_reconstructed_pcax_reconstructed_nmf)ax[ imshow(orig reshape(image_shape)ax[ imshow(rec_kmeans reshape(image_shape)ax[ imshow(rec_pca reshape(image_shape)ax[ imshow(rec_nmf reshape(image_shape)axes[ set_ylabel("original"axes[ set_ylabel("kmeans"axes[ set_ylabel("pca"axes[ set_ylabel("nmf"clustering