{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example Term Project: Privacy-Preserving Analysis of a Public Dataset\n",
    "\n",
    "**Author:** Jane Student  \n",
    "**Course:** CSCI 49395 — Big Data Analytics and Applied Privacy\n",
    "\n",
    "This notebook demonstrates the expected structure for the final-project notebook deliverable:\n",
    "an introduction, a reproducible data-load step, an analysis step, an explicit privacy analysis,\n",
    "and a conclusion. Replace every section with your own work."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Data load: read the raw dataset. Keep raw inputs read-only; never edit them by hand.\n",
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv(\"data/raw/records.csv\")\n",
    "print(df.shape)\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Analysis: a simple aggregate over the dataset.\n",
    "summary = df.groupby(\"zip_code\")[\"age\"].agg([\"count\", \"mean\"]).reset_index()\n",
    "summary.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Privacy analysis: check k-anonymity of the quasi-identifiers before releasing aggregates.\n",
    "QUASI_IDENTIFIERS = [\"zip_code\", \"age\", \"sex\"]\n",
    "group_sizes = df.groupby(QUASI_IDENTIFIERS).size()\n",
    "k = int(group_sizes.min())\n",
    "print(f\"Smallest equivalence class (k) = {k}\")\n",
    "print(\"Meets k>=5 threshold:\" , k >= 5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Conclusion\n",
    "\n",
    "Summarize your findings, the privacy/utility trade-off you observed, the limitations of your\n",
    "approach, and what you would do next with more time. State clearly which claims are supported\n",
    "by your analysis and which are speculative."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
