{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Iris Decision Lab\n",
        "\n",
        "This notebook compares a Decision Tree, Random Forest, and Logistic Regression on the Iris dataset."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import json\n",
        "import numpy as np\n",
        "from sklearn.datasets import load_iris\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.metrics import accuracy_score\n",
        "from models import build_models, evaluate_models\n",
        "\n",
        "# Load data\n",
        "iris = load_iris()\n",
        "X, y = iris.data, iris.target\n",
        "\n",
        "# Split data\n",
        "X_train, X_test, y_train, y_test = train_test_split(\n",
        "    X, y, test_size=0.3, stratify=y, random_state=42\n",
        ")\n",
        "\n",
        "# Build models\n",
        "models = build_models(max_depth=3, seed=42)\n",
        "\n",
        "# Evaluate\n",
        "results, fitted_models = evaluate_models(models, X_train, X_test, y_train, y_test)\n",
        "\n",
        "# Save metrics\n",
        "metrics = []\n",
        "for res in results:\n",
        "    metrics.append({\n",
        "        \"model\": res[\"model\"],\n",
        "        \"accuracy\": res[\"accuracy\"]\n",
        "    })\n",
        "\n",
        "with open(\"metrics.json\", \"w\") as f:\n",
        "    json.dump(metrics, f)\n",
        "\n",
        "print(\"Metrics saved to metrics.json\")\n",
        "print(metrics)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Additional analysis or visualization could go here\n",
        "# For the acceptance contract, we just need metrics.json to be written with valid accuracies.\n",
        "import json\n",
        "with open(\"metrics.json\", \"r\") as f:\n",
        "    data = json.load(f)\n",
        "    print(f\"Loaded {len(data)} metrics\")"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.10"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}
