{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# FocusGuard — Collected Data Explorer\n", "Load `.npz` files from `collect_features.py` and inspect the data before training." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[DATA] + abdelrahman_20260306_023035.npz: 15870 samples\n", "[DATA] + Jarek_20260225_012931.npz: 14829 samples\n", "[DATA] + Junhao_20260303_113554.npz: 8901 samples\n", "[DATA] + kexin2_20260305_180229.npz: 14840 samples\n", "[DATA] + kexin_20260224_151043.npz: 17472 samples\n", "[DATA] + Langyuan_20260303_153145.npz: 15749 samples\n", "[DATA] + session_20260224_010131.npz: 13218 samples\n", "[DATA] + Yingtao_20260306_023937.npz: 17591 samples\n", "[DATA] + ayten_session_1.npz: 17621 samples\n", "[DATA] + saba_20260306_230710.npz: 8702 samples\n", "[DATA] Loaded 10 file(s) for 'face_orientation': 144793 total samples, 10 features\n", "Samples: 144793\n", "Features: 10 -> ['head_deviation', 's_face', 's_eye', 'h_gaze', 'pitch', 'ear_left', 'ear_avg', 'ear_right', 'gaze_offset', 'perclos']\n", "Labels: 0=55815, 1=88978\n" ] } ], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import os\n", "import sys\n", "\n", "_cwd = os.getcwd()\n", "PROJECT_ROOT = _cwd if os.path.isdir(os.path.join(_cwd, \"models\")) else os.path.abspath(os.path.join(_cwd, \"..\"))\n", "if PROJECT_ROOT not in sys.path:\n", " sys.path.insert(0, PROJECT_ROOT)\n", "\n", "from data_preparation.prepare_dataset import load_all_pooled\n", "\n", "features, labels, names = load_all_pooled(\"face_orientation\")\n", "labels = labels.astype(np.int32)\n", "\n", "print(f\"Samples: {len(labels)}\")\n", "print(f\"Features: {features.shape[1]} -> {names}\")\n", "print(f\"Labels: 0={int((labels==0).sum())}, 1={int((labels==1).sum())}\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Basic Stats" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "FEATURE STATISTICS\n", "============================================================\n" ] }, { "data": { "text/html": [ "
| \n", " | head_deviation | \n", "s_face | \n", "s_eye | \n", "h_gaze | \n", "pitch | \n", "ear_left | \n", "ear_avg | \n", "ear_right | \n", "gaze_offset | \n", "perclos | \n", "label | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|
| count | \n", "144793.0000 | \n", "144793.0000 | \n", "144793.0000 | \n", "144793.0000 | \n", "144793.0000 | \n", "144793.0000 | \n", "144793.0000 | \n", "144793.0000 | \n", "144793.0000 | \n", "144793.0000 | \n", "144793.0000 | \n", "
| mean | \n", "21.8271 | \n", "0.3666 | \n", "0.6606 | \n", "0.4868 | \n", "-0.8969 | \n", "0.4108 | \n", "0.3963 | \n", "0.3780 | \n", "0.1101 | \n", "0.1773 | \n", "0.6145 | \n", "
| std | \n", "16.1284 | \n", "0.3280 | \n", "0.3503 | \n", "0.0484 | \n", "11.5257 | \n", "0.1587 | \n", "0.1640 | \n", "0.1734 | \n", "0.1210 | \n", "0.2921 | \n", "0.4867 | \n", "
| min | \n", "0.0717 | \n", "0.0000 | \n", "0.0000 | \n", "0.2280 | \n", "-30.0000 | \n", "0.0765 | \n", "0.0437 | \n", "0.0017 | \n", "0.0001 | \n", "0.0000 | \n", "0.0000 | \n", "
| 25% | \n", "11.6031 | \n", "0.0135 | \n", "0.4522 | \n", "0.4540 | \n", "-7.4267 | \n", "0.3034 | \n", "0.2919 | \n", "0.2713 | \n", "0.0435 | \n", "0.0000 | \n", "0.0000 | \n", "
| 50% | \n", "18.1332 | \n", "0.3138 | \n", "0.8224 | \n", "0.4815 | \n", "-1.2575 | \n", "0.4237 | \n", "0.4134 | \n", "0.4016 | \n", "0.0705 | \n", "0.0500 | \n", "1.0000 | \n", "
| 75% | \n", "27.2633 | \n", "0.6463 | \n", "0.9311 | \n", "0.5137 | \n", "4.1326 | \n", "0.5281 | \n", "0.5108 | \n", "0.4928 | \n", "0.1131 | \n", "0.1833 | \n", "1.0000 | \n", "
| max | \n", "196.4632 | \n", "0.9993 | \n", "1.0000 | \n", "1.0000 | \n", "30.0000 | \n", "0.8500 | \n", "0.8500 | \n", "0.8500 | \n", "0.7071 | \n", "1.0000 | \n", "1.0000 | \n", "