Conta o total de amostras de imagens


In [81]:
from sklearn.datasets import fetch_olivetti_faces
from pylab import *
from plotly import tools

faces = fetch_olivetti_faces()
       
#Quantidade
print "\nQuantidade Total de Dados: "
print faces.target.shape


Quantidade Total de Dados: 
(400,)

Mostra as primeiras 64 imagens


In [82]:
faces = fetch_olivetti_faces()

# set up the figure
fig = plt.figure(figsize=(10, 10))  # figure size in inches
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)

# plot the faces:
for i in range(64):
    ax = fig.add_subplot(8, 8, i + 1, xticks=[], yticks=[])
    ax.imshow(faces.images[i], cmap=plt.cm.bone, interpolation='nearest')


Aplica escala de cinza


In [83]:
total = 10
for i in range(total):
    face = faces.images[i]
    subplot(1, total, i + 1)
    imshow(face.reshape((64, 64)), cmap='gray')
    #imshow(face, cmap='gray')
    axis('off')