from sklearn decomposition import nmf nmf nmf(n_components= random_state= nmf fit(x_trainx_train_nmf nmf transform(x_trainx_test_nmf nmf transform(x_testfixaxes plt subplots( figsize=( )subplot_kw={'xticks'()'yticks'()}for (componentaxin enumerate(zip(nmf components_axes ravel()))ax imshow(component reshape(image_shape)ax set_title("{componentformat( )figure - the components found by nmf on the faces dataset when using components these components are all positiveand so resemble prototypes of faces much more so than the components shown for pca in figure - for exampleone can clearly see that component shows face rotated somewhat to the rightwhile component shows face somewhat rotated to the left let' look at the images for which these components are particularly strongshown in figures - and - dimensionality reductionfeature extractionand manifold learning