{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Eigenface" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from sklearn.decomposition import PCA\n", "from sklearn.datasets import fetch_olivetti_faces" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(400, 64, 64)\n" ] } ], "source": [ "# Step 1: Load Olivetti Faces dataset\n", "faces_data = fetch_olivetti_faces(shuffle=True)\n", "images = faces_data.images # Shape (400, 64, 64)\n", "targets = faces_data.target # Labels (0-39, each person has 10 images)\n", "\n", "print(images.shape)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
PCA(n_components=5)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
PCA(n_components=5)