Python sklearn.datasets.fetch_olivetti_faces() Examples
The following are 2
code examples of sklearn.datasets.fetch_olivetti_faces().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sklearn.datasets
, or try the search function
.
Example #1
Source File: skimage_lbp_simple.py From optuna with MIT License | 7 votes |
def load_data(): rng = np.random.RandomState(0) dataset = fetch_olivetti_faces(shuffle=True, random_state=rng) faces = dataset.images target = dataset.target classes = np.unique(target) classes.sort() ref_index = np.argmax(target == classes[:, None], axis=1) valid_index = np.delete(np.arange(len(faces)), ref_index) x_ref = faces[ref_index] y_ref = target[ref_index] x_valid = faces[valid_index] y_valid = target[valid_index] return x_ref, x_valid, y_ref, y_valid
Example #2
Source File: svd.py From ml_code with Apache License 2.0 | 5 votes |
def getImgAsMat(index): ds = datasets.fetch_olivetti_faces() return np.mat(ds.images[index])