from sklearn.neighbors import KNeighborsRegressor from sklearn.linear_model import LinearRegression,Ridge,Lasso from sklearn.ensemble import ExtraTreesRegressor
from sklearn import datasets
faces = datasets.fetch_olivetti_faces()
faces
{'data': array([[0.30991736, 0.3677686 , 0.41735536, ..., 0.15289256, 0.16115703, 0.1570248 ], [0.45454547, 0.47107437, 0.5123967 , ..., 0.15289256, 0.15289256, 0.15289256], ..., [0.5165289 , 0.46280992, 0.28099173, ..., 0.35950413, 0.3553719 , 0.38429752]], dtype=float32), 'images': array([[[0.30991736, 0.3677686 , 0.41735536, ..., 0.37190083, 0.3305785 , 0.30578512], ..., [0.20247933, 0.20661157, 0.20247933, ..., 0.15289256, 0.16115703, 0.1570248 ]], [0.3677686 , 0.40495867, 0.3966942 , ..., 0.35950413, 0.3553719 , 0.38429752]]], dtype=float32), 'target': array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, ..., 35, 35, 35, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39]), 'DESCR': 'Modified Olivetti faces dataset.\n\nThe original database was available from\n\n http://www.cl./research/dtg/attarchive/facedatabase.html\n\nThe version retrieved here comes in MATLAB format from the personal\nweb page of Sam Roweis:\n\n http://www.cs./~roweis/\n\nThere are ten different images of each of 40 distinct subjects. For some\nsubjects, the images were taken at different times, varying the lighting,\nfacial expressions (open / closed eyes, smiling / not smiling) and facial\ndetails (glasses / no glasses). All the images were taken against a dark\nhomogeneous background with the subjects in an upright, frontal position (with\ntolerance for some side movement).\n\nThe original dataset consisted of 92 x 112, while the Roweis version\nconsists of 64x64 images.\n'}
data = faces.data target = faces.target data.shape
(400, 4096)
faces.images.shape
(400, 64, 64)
import matplotlib.pyplot as plt %matplotlib inline