{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Experiment Data Analysis\n",
    "\n",
    "This notebook analyzes the experiment data collected from AWS and IBM cloud environments comparing CAS and Karpenter autoscaling."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "source": [
    "import json\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "from pathlib import Path\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "source": [
    "# Set up paths\n",
    "BASE_PATH = Path('.')\n",
    "AWS_PATH = BASE_PATH / 'aws'\n",
    "IBM_PATH = BASE_PATH / 'ibm'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "source": [
    "def load_json_file(path):\n",
    "    \"\"\"Load and parse a JSON file\"\"\"\n",
    "    with open(path) as f:\n",
    "        return json.load(f)\n",
    "\n",
    "def parse_latency_data(path):\n",
    "    \"\"\"Parse node latency measurement data\"\"\"\n",
    "    data = load_json_file(path)\n",
    "    return pd.DataFrame(data)\n",
    "\n",
    "def parse_billing_data(path):\n",
    "    \"\"\"Parse AWS billing metrics data\"\"\"\n",
    "    data = load_json_file(path)\n",
    "    return pd.DataFrame(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "source": [
    "# Load AWS homogeneous CAS data\n",
    "aws_homo_cas_path = AWS_PATH / 'homogenous/cas/3c29adda-1a6f-4548-a3a6-0faad0bf8013-eks-cas'\n",
    "aws_cas_latency = parse_latency_data(aws_homo_cas_path / 'nodeLatencyMeasurement-api-intensive.json')\n",
    "aws_cas_billing = parse_billing_data(aws_homo_cas_path / 'aws_billing_metrics_cas.json')\n",
    "\n",
    "# Load AWS homogeneous Karpenter data\n",
    "aws_homo_karp_path = AWS_PATH / 'homogenous/karpenter/3c29adda-1a6f-4548-a3a6-0faad0bf8013-eks-karpenter'\n",
    "aws_karp_latency = parse_latency_data(aws_homo_karp_path / 'nodeLatencyMeasurement-api-intensive.json')\n",
    "aws_karp_billing = parse_billing_data(aws_homo_karp_path / 'aws_billing_metrics_karpenter.json')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Initial Data Analysis\n",
    "\n",
    "Let's examine the structure and basic statistics of our data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "source": [
    "# Display basic information about the latency datasets\n",
    "print(\"AWS CAS Latency Data Info:\")\n",
    "print(aws_cas_latency.info())\n",
    "print(\"\\nAWS Karpenter Latency Data Info:\")\n",
    "print(aws_karp_latency.info())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "source": [
    "# Basic statistical comparison\n",
    "print(\"AWS CAS Latency Statistics:\")\n",
    "print(aws_cas_latency.describe())\n",
    "print(\"\\nAWS Karpenter Latency Statistics:\")\n",
    "print(aws_karp_latency.describe())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
