Created
August 12, 2018 22:49
-
-
Save mick001/e22582b1d67e02396dcbd199d60d117e to your computer and use it in GitHub Desktop.
Download Olivetti faces dataset in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imports | |
from sklearn.datasets import fetch_olivetti_faces | |
import numpy as np | |
# Download Olivetti faces dataset | |
olivetti = fetch_olivetti_faces() | |
x = olivetti.images | |
y = olivetti.target | |
# Print info on shapes and reshape where necessary | |
print("Original x shape:", x.shape) | |
X = x.reshape((400, 4096)) | |
print("New x shape:", X.shape) | |
print("y shape", y.shape) | |
# Save the numpy arrays | |
np.savetxt("C://olivetti_X.csv", X, delimiter = ",") | |
np.savetxt("C://olivetti_y.csv", y, delimiter = ",", fmt = '%d') | |
print("\nDownloading and reshaping done!") | |
################################################################################ | |
# OUTPUT | |
################################################################################ | |
# | |
# Original x shape: (400, 64, 64) | |
# New x shape: (400, 4096) | |
# y shape (400,) | |
# | |
# Downloading and reshaping done! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you!