{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Lesson 22: Portfolio Interview Readiness and Case Defense\n",
        "\n",
        "**CS230 inspiration:** Final report, poster session, reading research papers, and career readiness.\n",
        "\n",
        "**Demand forecasting focus:** Turn the curriculum into a portfolio artifact a hiring manager can evaluate quickly.\n",
        "\n",
        "**Learning objectives**\n",
        "\n",
        "- Map coursework artifacts to interview evidence.\n",
        "- Prepare an executive narrative, technical defense, and risk register.\n",
        "- Practice answering senior-level follow-up questions.\n",
        "\n",
        "**Senior-readiness checkpoint:** You can defend the project like an owner: assumptions, tradeoffs, failures, decision impact, and next steps.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Code Cell 1 Explanation\n",
        "\n",
        "**What this cell does:** This setup cell imports the shared scientific Python stack and the curriculum helpers used by later cells. It also establishes the deterministic seed convention so repeated runs are comparable.\n",
        "\n",
        "**Why it matters:** A restart-and-run notebook should make its dependencies explicit before any modeling work begins. For forecasting, reproducibility is especially important because small data or seed changes can change validation conclusions.\n",
        "\n",
        "**Key operations to notice:** confirm that shared helper imports match the lesson's code path; check that `SEED` is defined before any generated data or model training\n",
        "\n",
        "**What to inspect:** Check that imports are grouped by purpose: general analysis packages, forecasting data helpers, metrics, plotting utilities, and any lesson-specific libraries.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n",
        "import numpy as np\n",
        "import pandas as pd\n",
        "\n",
        "from demand_forecasting_curriculum.data import (\n",
        "    DEFAULT_FEATURE_COLUMNS,\n",
        "    generate_daily_demand,\n",
        "    make_sequence_dataset,\n",
        "    make_supervised_table,\n",
        "    time_series_split,\n",
        ")\n",
        "from demand_forecasting_curriculum.metrics import (\n",
        "    interval_coverage,\n",
        "    mase,\n",
        "    pinball_loss,\n",
        "    smape,\n",
        "    wmape,\n",
        ")\n",
        "from demand_forecasting_curriculum.plotting import plot_predictions, plot_series\n",
        "\n",
        "SEED = 42\n",
        "np.random.seed(SEED)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Hiring-Manager Signal\n",
        "\n",
        "A portfolio is not impressive because it contains many notebooks. It is impressive when each artifact proves a capability: problem framing, data judgment, statistical rigor, modeling skill, business impact, and communication.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Code Cell 2 Explanation\n",
        "\n",
        "**What this cell does:** This cell advances **Portfolio Interview Readiness and Case Defense** by working on portfolio communication. It creates or updates `evidence_map` and prepares evidence that later cells use rather than hiding state in prose.\n",
        "\n",
        "**Why it matters:** The goal is tied to this lesson's forecasting focus: Turn the curriculum into a portfolio artifact a hiring manager can evaluate quickly. Each object is kept inspectable so the learner can connect code, assumptions, and modeling consequences.\n",
        "\n",
        "**Key operations to notice:** creates an inspectable table for assumptions, metrics, or decisions\n",
        "\n",
        "**What to inspect:** Before moving on, inspect shapes, date ranges, metric values, segment behavior, or generated tables. If a value looks surprisingly good, surprisingly bad, or unavailable at forecast time, treat that as a modeling clue.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "evidence_map = pd.DataFrame(\n",
        "    [\n",
        "        (\"Problem framing\", \"00, 02, 17, 22\", \"Target, horizon, grain, decision, and success metric are explicit.\"),\n",
        "        (\"Synthetic data generation\", \"01\", \"DGP design, realism checks, adversarial validation, synthetic data card.\"),\n",
        "        (\"SQL and data modeling\", \"18\", \"Relational joins, window features, feature contract, leakage checks.\"),\n",
        "        (\"Forecasting baselines\", \"02, 06, 20\", \"Naive, tabular, hierarchical, and segment-level comparisons.\"),\n",
        "        (\"Deep learning implementation\", \"03, 04, 07, 08, 09, 11\", \"NumPy backprop, PyTorch MLP/CNN/GRU/Transformer, embeddings.\"),\n",
        "        (\"Agentic DL iteration\", \"13\", \"Ralph loop spec, one-change loops, backpressure gates, learning log.\"),\n",
        "        (\"Experimentation and causality\", \"19\", \"Randomization, diff-in-diff, CUPED, MDE, causal recommendation.\"),\n",
        "        (\"Uncertainty and decisions\", \"10, 21\", \"Quantiles, interval coverage, newsvendor cost, service-level tradeoffs.\"),\n",
        "        (\"Diagnostics and monitoring\", \"06, 14, 15, 16\", \"Error slicing, interpretability, drift, contracts, rollout plan.\"),\n",
        "        (\"Communication\", \"17, 22\", \"Executive summary, model card, risk register, interview defense.\"),\n",
        "    ],\n",
        "    columns=[\"capability\", \"notebooks\", \"proof\"],\n",
        ")\n",
        "evidence_map\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Code Cell 3 Explanation\n",
        "\n",
        "**What this cell does:** This cell advances **Portfolio Interview Readiness and Case Defense** by working on portfolio communication. It creates or updates `hiring_scorecard` and prepares evidence that later cells use rather than hiding state in prose.\n",
        "\n",
        "**Why it matters:** The goal is tied to this lesson's forecasting focus: Turn the curriculum into a portfolio artifact a hiring manager can evaluate quickly. Each object is kept inspectable so the learner can connect code, assumptions, and modeling consequences.\n",
        "\n",
        "**Key operations to notice:** creates an inspectable table for assumptions, metrics, or decisions\n",
        "\n",
        "**What to inspect:** Before moving on, inspect shapes, date ranges, metric values, segment behavior, or generated tables. If a value looks surprisingly good, surprisingly bad, or unavailable at forecast time, treat that as a modeling clue.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "hiring_scorecard = pd.DataFrame(\n",
        "    [\n",
        "        (\"Can they design useful synthetic data?\", \"Yes, if lesson 01 includes realism checks and a clear data card.\"),\n",
        "        (\"Can they use AI loops safely?\", \"Yes, if lesson 13 keeps scope narrow and gates every change.\"),\n",
        "        (\"Would I trust this person with messy data?\", \"Yes, if lesson 18 is completed with contract checks.\"),\n",
        "        (\"Can they reason statistically?\", \"Yes, if lesson 19 includes limits and causal assumptions.\"),\n",
        "        (\"Can they build models?\", \"Yes, multiple baselines and neural architectures are represented.\"),\n",
        "        (\"Can they improve a decision?\", \"Yes, lesson 21 connects forecasts to inventory costs.\"),\n",
        "        (\"Can they communicate with stakeholders?\", \"Yes, if lessons 17 and 22 are delivered as concise artifacts.\"),\n",
        "        (\"What would still concern me?\", \"Synthetic data is useful but must be corroborated with real data.\"),\n",
        "    ],\n",
        "    columns=[\"hiring-manager question\", \"evidence-based answer\"],\n",
        ")\n",
        "hiring_scorecard\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Code Cell 4 Explanation\n",
        "\n",
        "**What this cell does:** This cell advances **Portfolio Interview Readiness and Case Defense** by working on imports and project setup. It creates or updates `defense_questions` and prepares evidence that later cells use rather than hiding state in prose.\n",
        "\n",
        "**Why it matters:** The goal is tied to this lesson's forecasting focus: Turn the curriculum into a portfolio artifact a hiring manager can evaluate quickly. Each object is kept inspectable so the learner can connect code, assumptions, and modeling consequences.\n",
        "\n",
        "**Key operations to notice:** creates an inspectable table for assumptions, metrics, or decisions\n",
        "\n",
        "**What to inspect:** Before moving on, inspect shapes, date ranges, metric values, segment behavior, or generated tables. If a value looks surprisingly good, surprisingly bad, or unavailable at forecast time, treat that as a modeling clue.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "defense_questions = pd.DataFrame(\n",
        "    [\n",
        "        (\"Data\", \"Which features are known at forecast time, and how did you prove that?\"),\n",
        "        (\"Statistics\", \"How would you measure whether promotions caused incremental demand?\"),\n",
        "        (\"Modeling\", \"Why did the deep model beat or fail to beat the strongest baseline?\"),\n",
        "        (\"Decision\", \"Which forecast quantile should inventory use, and what cost tradeoff does it imply?\"),\n",
        "        (\"Systems\", \"How would you monitor this model after launch and decide when to retrain?\"),\n",
        "        (\"Leadership\", \"What would you cut from scope if the business needed a result in two weeks?\"),\n",
        "    ],\n",
        "    columns=[\"theme\", \"panel question\"],\n",
        ")\n",
        "defense_questions\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Code Cell 5 Explanation\n",
        "\n",
        "**What this cell does:** This cell advances **Portfolio Interview Readiness and Case Defense** by working on portfolio communication. It creates or updates `risk_register` and prepares evidence that later cells use rather than hiding state in prose.\n",
        "\n",
        "**Why it matters:** The goal is tied to this lesson's forecasting focus: Turn the curriculum into a portfolio artifact a hiring manager can evaluate quickly. Each object is kept inspectable so the learner can connect code, assumptions, and modeling consequences.\n",
        "\n",
        "**Key operations to notice:** creates an inspectable table for assumptions, metrics, or decisions\n",
        "\n",
        "**What to inspect:** Before moving on, inspect shapes, date ranges, metric values, segment behavior, or generated tables. If a value looks surprisingly good, surprisingly bad, or unavailable at forecast time, treat that as a modeling clue.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "risk_register = pd.DataFrame(\n",
        "    [\n",
        "        (\"Synthetic data\", \"May not reflect real retail messiness\", \"Add a real public dataset extension.\"),\n",
        "        (\"Promotion causality\", \"Observational promo effects can be biased\", \"Prefer randomized tests or quasi-experimental designs.\"),\n",
        "        (\"Stockout censoring\", \"Observed sales may understate true demand\", \"Model censoring and inventory availability explicitly.\"),\n",
        "        (\"Hierarchy conflicts\", \"Forecasts may disagree across planning levels\", \"Use reconciliation and report accuracy at every level.\"),\n",
        "        (\"Metric mismatch\", \"Lower WMAPE may not lower inventory cost\", \"Evaluate business decision metrics directly.\"),\n",
        "    ],\n",
        "    columns=[\"risk\", \"why it matters\", \"mitigation\"],\n",
        ")\n",
        "risk_register\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Lesson Recap\n",
        "\n",
        "In this lesson, we used 5 runnable code cells to work through **Portfolio Interview Readiness and Case Defense**. The practical focus was: Turn the curriculum into a portfolio artifact a hiring manager can evaluate quickly.\n",
        "\n",
        "We did this because deep learning for demand forecasting is not only about choosing an architecture. The learner needs to understand the data contract, the target and horizon, the validation path, the metric, and the operational decision supported by the forecast.\n",
        "\n",
        "The core takeaways were:\n",
        "\n",
        "- Map coursework artifacts to interview evidence.\n",
        "- Prepare an executive narrative, technical defense, and risk register.\n",
        "- Practice answering senior-level follow-up questions.\n",
        "\n",
        "By the end, you should be able to explain not just what the code produced, but why each step was necessary and what could go wrong if the same step were skipped or performed with leakage.\n",
        "\n",
        "**Senior-readiness reminder:** You can defend the project like an owner: assumptions, tradeoffs, failures, decision impact, and next steps.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Exercises\n",
        "\n",
        "- Create a three-slide project walkthrough: problem, evidence, decision.\n",
        "- Record a five-minute verbal defense using the panel questions.\n",
        "- Replace one synthetic-data lesson with a real dataset and update the risk register.\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python (deep-learning-demand)",
      "language": "python",
      "name": "deep-learning-demand"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}
