{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "markov_check-0",
   "metadata": {},
   "source": [
    "# Markov check: do the data contradict a graph?\n",
    "\n",
    "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Abel-ai-lab/andrey/blob/main/examples/markov_check.ipynb)\n",
    "\n",
    "A graph implies conditional independences: each variable is independent of every earlier variable\n",
    "in a causal order that is not its parent, given its parents. `andrey.markov_check` tests each one\n",
    "with a conditional-independence test and asks whether the p-values look uniform, as they do when\n",
    "every independence holds. A small uniformity p-value rejects the graph. Here the check runs on data\n",
    "simulated on the ALARM network, whose true graph we know, to show what it catches, what it misses,\n",
    "and how it can choose among graphs."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "markov_check-1",
   "metadata": {},
   "source": [
    "## Start\n",
    "\n",
    "Choose a CPU runtime and run this cell first. In Colab it installs `andrey-core==0.13.0` from PyPI;\n",
    "local kernels use the installed environment."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "markov_check-2",
   "metadata": {
    "tags": [
     "colab-setup"
    ]
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import sys\n",
    "\n",
    "IN_COLAB = \"google.colab\" in sys.modules\n",
    "\n",
    "if IN_COLAB:\n",
    "    os.environ[\"ANDREY_DEVICE\"] = \"cpu\"\n",
    "    !pip install --quiet \"andrey-core[viz]==0.13.0\" pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "markov_check-3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "import andrey\n",
    "import andrey.viz\n",
    "from andrey import GraphStructure\n",
    "from andrey.data import load_dataset\n",
    "from andrey.metrics import shd, to_cpdag"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "markov_check-4",
   "metadata": {},
   "source": [
    "ALARM is a published network of 37 variables and 46 arcs. `load_dataset` simulates rows on it from\n",
    "a linear-Gaussian model. A graph fitted to some rows can pass a check on those rows because the fit\n",
    "made its independences true there, so the check needs rows the graph was not learned from. We learn\n",
    "on the first 1,000 rows and check on the other 1,000."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "markov_check-5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "37 variables, 46 true edges\n"
     ]
    }
   ],
   "source": [
    "alarm = load_dataset(\"alarm\", n=2000, seed=1)\n",
    "data, truth = alarm.data, alarm.graph\n",
    "learn, held = data.iloc[:1000], data.iloc[1000:]\n",
    "true_cpdag = to_cpdag(truth)\n",
    "print(data.shape[1], \"variables,\", len(truth.oriented_edges()), \"true edges\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "markov_check-6",
   "metadata": {},
   "source": [
    "## Check a graph\n",
    "\n",
    "The true graph is the control: its independences hold, so the check should not reject it. The\n",
    "result prints the verdict, the number of independences tested, and the uniformity statistic."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "markov_check-7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not rejected: the p-values of the 620 independences the graph implies are consistent with uniform (Anderson-Darling p = 0.656 > 0.05); 5.6% have p < 0.05, about 5% expected. A pass does not show the edges are right: a graph with extra edges also passes.\n",
      "  620 tests | Anderson-Darling A^2 = 0.592 | each test on 500 rows | indep_test fisherz\n"
     ]
    }
   ],
   "source": [
    "check = andrey.markov_check(truth, held)\n",
    "print(check)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "markov_check-8",
   "metadata": {},
   "source": [
    "## A damaged graph is rejected\n",
    "\n",
    "Remove the edge `CO -> BP` from the true graph. The graph now claims that `BP` is independent of\n",
    "the causes of `CO`, such as `LVFAILURE`, given `TPR`, which the data contradict. `table()` lists\n",
    "every tested independence with its p-value, so the smallest ones show where the graph is wrong:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "markov_check-9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rejected: the p-values of the 621 independences the graph implies are not uniform (Anderson-Darling p = 9.66e-07 <= 0.05); 8.5% have p < 0.05, about 5% expected.\n",
      "  621 tests | Anderson-Darling A^2 = 48.4 | each test on 500 rows | indep_test fisherz\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>x</th>\n",
       "      <th>y</th>\n",
       "      <th>given</th>\n",
       "      <th>p_value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>185</th>\n",
       "      <td>BP</td>\n",
       "      <td>INSUFFANESTH</td>\n",
       "      <td>[TPR]</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>188</th>\n",
       "      <td>BP</td>\n",
       "      <td>LVFAILURE</td>\n",
       "      <td>[TPR]</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>197</th>\n",
       "      <td>BP</td>\n",
       "      <td>STROKEVOLUME</td>\n",
       "      <td>[TPR]</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      x             y  given  p_value\n",
       "185  BP  INSUFFANESTH  [TPR]      0.0\n",
       "188  BP     LVFAILURE  [TPR]      0.0\n",
       "197  BP  STROKEVOLUME  [TPR]      0.0"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def with_pair(graph, source, target, edge):\n",
    "    \"\"\"Return a copy of the DAG with `source -> target` added, or removed when not `edge`.\"\"\"\n",
    "    marks = graph.to_numpy().copy()\n",
    "    i, j = graph.labels.index(source), graph.labels.index(target)\n",
    "    marks[i, j], marks[j, i] = (1, 2) if edge else (0, 0)  # tail at source, arrowhead at target\n",
    "    return GraphStructure.from_numpy(marks, kind=\"dag\", labels=graph.labels)\n",
    "\n",
    "\n",
    "damaged = with_pair(truth, \"CO\", \"BP\", edge=False)\n",
    "check = andrey.markov_check(damaged, held)\n",
    "print(check)\n",
    "pd.DataFrame(check.table()).nsmallest(3, \"p_value\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "markov_check-10",
   "metadata": {},
   "source": [
    "## What a pass does not show\n",
    "\n",
    "The check rejects a missing edge only when the data can see the dependence. `PULMEMBOLUS -> PAP`\n",
    "is weak enough here that a graph without it still passes. A graph with an extra edge passes too,\n",
    "because an extra edge removes an independence from the graph's claims and leaves the rest true.\n",
    "So a pass says the data do not contradict the graph, not that its edges are right:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "markov_check-11",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>graph</th>\n",
       "      <th>edges</th>\n",
       "      <th>tests</th>\n",
       "      <th>uniformity p</th>\n",
       "      <th>verdict</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>without PULMEMBOLUS -&gt; PAP</td>\n",
       "      <td>45</td>\n",
       "      <td>621</td>\n",
       "      <td>0.216</td>\n",
       "      <td>not rejected</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>plus HYPOVOLEMIA -&gt; CVP</td>\n",
       "      <td>47</td>\n",
       "      <td>619</td>\n",
       "      <td>0.903</td>\n",
       "      <td>not rejected</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        graph  edges  tests  uniformity p       verdict\n",
       "0  without PULMEMBOLUS -> PAP     45    621         0.216  not rejected\n",
       "1     plus HYPOVOLEMIA -> CVP     47    619         0.903  not rejected"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "variants = {\n",
    "    \"without PULMEMBOLUS -> PAP\": with_pair(truth, \"PULMEMBOLUS\", \"PAP\", edge=False),\n",
    "    \"plus HYPOVOLEMIA -> CVP\": with_pair(truth, \"HYPOVOLEMIA\", \"CVP\", edge=True),\n",
    "}\n",
    "rows = []\n",
    "for name, graph in variants.items():\n",
    "    check = andrey.markov_check(graph, held)\n",
    "    rows.append(\n",
    "        {\n",
    "            \"graph\": name,\n",
    "            \"edges\": len(graph.oriented_edges()),\n",
    "            \"tests\": check.n_tests,\n",
    "            \"uniformity p\": round(check.uniformity_p_value, 3),\n",
    "            \"verdict\": \"not rejected\" if check.passed else \"rejected\",\n",
    "        }\n",
    "    )\n",
    "pd.DataFrame(rows)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "markov_check-12",
   "metadata": {},
   "source": [
    "## Choosing a graph: the sparsest one that passes\n",
    "\n",
    "When the truth is unknown, Ramsey, Andrews, and Spirtes (2024) use the check to choose among the\n",
    "graphs a method returns over a range of one setting: drop the graphs the data reject and keep the\n",
    "sparsest of the rest, the simplest explanation the data allow. GES's `penalty_discount` multiplies\n",
    "the BIC penalty, and a larger value gives fewer edges. Fit GES on the learn rows over five values\n",
    "and check each fit on the held rows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "markov_check-13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>penalty_discount</th>\n",
       "      <th>edges</th>\n",
       "      <th>errors</th>\n",
       "      <th>uniformity p</th>\n",
       "      <th>verdict</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.5</td>\n",
       "      <td>59</td>\n",
       "      <td>18</td>\n",
       "      <td>0.267</td>\n",
       "      <td>not rejected</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.0</td>\n",
       "      <td>52</td>\n",
       "      <td>9</td>\n",
       "      <td>0.675</td>\n",
       "      <td>not rejected</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2.0</td>\n",
       "      <td>51</td>\n",
       "      <td>8</td>\n",
       "      <td>0.149</td>\n",
       "      <td>not rejected</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.0</td>\n",
       "      <td>50</td>\n",
       "      <td>15</td>\n",
       "      <td>0.247</td>\n",
       "      <td>not rejected</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>8.0</td>\n",
       "      <td>50</td>\n",
       "      <td>15</td>\n",
       "      <td>0.247</td>\n",
       "      <td>not rejected</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   penalty_discount  edges  errors  uniformity p       verdict\n",
       "0               0.5     59      18         0.267  not rejected\n",
       "1               1.0     52       9         0.675  not rejected\n",
       "2               2.0     51       8         0.149  not rejected\n",
       "3               4.0     50      15         0.247  not rejected\n",
       "4               8.0     50      15         0.247  not rejected"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rows, fits = [], {}\n",
    "for penalty in (0.5, 1, 2, 4, 8):\n",
    "    fit = andrey.ges(learn, penalty_discount=penalty)\n",
    "    check = andrey.markov_check(fit, held)\n",
    "    fits[penalty] = fit\n",
    "    rows.append(\n",
    "        {\n",
    "            \"penalty_discount\": penalty,\n",
    "            \"edges\": len(fit.structure.oriented_edges()),\n",
    "            \"errors\": shd(fit.structure, true_cpdag),\n",
    "            \"uniformity p\": round(check.uniformity_p_value, 3),\n",
    "            \"verdict\": \"not rejected\" if check.passed else \"rejected\",\n",
    "        }\n",
    "    )\n",
    "sweep = pd.DataFrame(rows)\n",
    "sweep"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "markov_check-14",
   "metadata": {},
   "source": [
    "The data reject none of the five graphs, so the rule picks the sparsest, 50 edges at\n",
    "`penalty_discount` 4 (8 returns the same graph). It is not the most accurate: its 15 errors against\n",
    "the true CPDAG are more than the 8 of the 51-edge graph at 2 and the 9 of the 52-edge graph at 1.\n",
    "The check rules out graphs the data contradict, and among the rest fewer edges is a preference,\n",
    "not a measure of accuracy."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "markov_check-15",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sparsest graph that passes: penalty_discount 4.0\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1207 763\" width=\"100%\" font-family=\"Inter, system-ui, sans-serif\"><rect width=\"1207\" height=\"763\" fill=\"#fafbfc\"/><line x1=\"171.82\" y1=\"356.50\" x2=\"262.31\" y2=\"356.50\" stroke=\"#e0982b\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><line x1=\"712.24\" y1=\"171.39\" x2=\"810.18\" y2=\"171.39\" stroke=\"#e0982b\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><line x1=\"1137.95\" y1=\"339.27\" x2=\"712.24\" y2=\"335.34\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1147.95,339.36 1137.99,334.27 1137.90,344.27\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1140.46\" y1=\"329.02\" x2=\"1072.52\" y2=\"294.33\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1149.37,333.57 1142.74,324.57 1138.19,333.47\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><path d=\"M 712.20 336.29 Q 885.10 350.50 1039.26 296.07\" fill=\"none\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1048.69,292.74 1037.59,291.36 1040.92,300.79\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"712.14\" y1=\"333.56\" x2=\"810.29\" y2=\"320.93\" stroke=\"#e0982b\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><line x1=\"705.91\" y1=\"346.38\" x2=\"811.38\" y2=\"522.93\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"816.51,531.51 815.68,520.36 807.09,525.49\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"287.39\" y1=\"361.29\" x2=\"364.03\" y2=\"391.65\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"373.33,395.33 365.87,387.00 362.19,396.29\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1052.05\" y1=\"309.62\" x2=\"952.15\" y2=\"547.70\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1055.92,300.40 1047.44,307.69 1056.66,311.56\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1044.76\" y1=\"272.08\" x2=\"956.27\" y2=\"182.76\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1051.80,279.18 1048.31,268.56 1041.21,275.60\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1042.69\" y1=\"486.45\" x2=\"957.44\" y2=\"551.78\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1050.63,480.37 1039.65,482.48 1045.73,490.42\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1038.00\" y1=\"470.96\" x2=\"960.09\" y2=\"465.86\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1047.97,471.61 1038.32,465.97 1037.67,475.95\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1042.36\" y1=\"629.12\" x2=\"957.62\" y2=\"567.35\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1050.44,635.01 1045.31,625.08 1039.42,633.16\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1037.95\" y1=\"642.89\" x2=\"960.12\" y2=\"643.61\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1047.95,642.79 1037.90,637.89 1037.99,647.88\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"362.79\" y1=\"687.25\" x2=\"288.09\" y2=\"700.96\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"372.63,685.44 361.89,682.33 363.70,692.17\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"393.47\" y1=\"672.89\" x2=\"471.16\" y2=\"574.55\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"477.36,566.70 467.23,571.45 475.08,577.65\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"397.76\" y1=\"679.02\" x2=\"563.57\" y2=\"624.34\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"573.07,621.21 562.01,619.59 565.14,629.09\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"59.05\" y1=\"730.97\" x2=\"145.82\" y2=\"730.97\" stroke=\"#e0982b\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><line x1=\"56.43\" y1=\"723.14\" x2=\"140.46\" y2=\"659.72\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"148.44,653.69 137.45,655.73 143.47,663.71\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"929.14\" y1=\"86.81\" x2=\"833.34\" y2=\"163.28\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"936.96,80.57 926.02,82.90 932.26,90.71\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"924.12\" y1=\"72.85\" x2=\"836.18\" y2=\"74.36\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"934.12,72.68 924.03,67.85 924.21,77.85\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"959.37\" y1=\"76.81\" x2=\"1039.27\" y2=\"105.19\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1048.70,108.53 1040.95,100.47 1037.60,109.90\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"959.37\" y1=\"68.11\" x2=\"1039.27\" y2=\"39.73\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1048.70,36.38 1037.60,35.02 1040.95,44.44\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"836.18\" y1=\"171.62\" x2=\"924.12\" y2=\"173.13\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"934.12,173.30 924.21,168.13 924.03,178.13\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"567.71\" y1=\"488.21\" x2=\"495.42\" y2=\"548.20\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"575.41,481.82 564.52,484.36 570.91,492.06\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"562.41\" y1=\"473.52\" x2=\"498.41\" y2=\"473.52\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"572.41,473.52 562.41,468.52 562.41,478.52\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"598.10\" y1=\"470.68\" x2=\"676.80\" y2=\"453.02\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"686.56,450.83 675.71,448.14 677.90,457.90\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"284.89\" y1=\"694.52\" x2=\"368.47\" y2=\"617.80\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"375.84,611.04 365.09,614.11 371.85,621.48\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"254.68\" y1=\"693.14\" x2=\"170.48\" y2=\"651.61\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"263.65,697.56 256.89,688.65 252.47,697.62\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"260.88\" y1=\"685.39\" x2=\"166.97\" y2=\"568.75\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"267.16,693.18 264.78,682.26 256.99,688.53\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"712.24\" y1=\"542.67\" x2=\"800.18\" y2=\"542.67\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"810.18,542.67 800.18,537.67 800.18,547.67\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"464.50\" y1=\"566.07\" x2=\"397.24\" y2=\"596.84\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"473.59,561.91 462.42,561.52 466.58,570.61\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><path d=\"M 465.97 544.22 Q 386.04 493.74 287.56 458.73\" fill=\"none\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"474.42,549.56 468.64,539.99 463.30,548.45\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"496.53\" y1=\"563.24\" x2=\"565.75\" y2=\"605.21\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"574.30,610.40 568.34,600.94 563.16,609.49\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"362.83\" y1=\"606.59\" x2=\"171.58\" y2=\"643.40\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"372.65,604.70 361.88,601.68 363.77,611.50\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"362.83\" y1=\"597.90\" x2=\"171.58\" y2=\"561.08\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"372.65,599.79 363.77,592.99 361.88,602.81\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"371.68\" y1=\"583.80\" x2=\"283.07\" y2=\"464.80\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"377.65,591.82 375.69,580.81 367.67,586.78\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"398.38\" y1=\"603.21\" x2=\"562.48\" y2=\"615.43\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"572.45,616.17 562.85,610.44 562.11,620.42\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"924.33\" y1=\"556.56\" x2=\"836.06\" y2=\"544.44\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"934.24,557.92 925.01,551.61 923.65,561.52\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"960.12\" y1=\"559.81\" x2=\"1037.95\" y2=\"560.54\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1047.95,560.63 1037.99,555.54 1037.90,565.54\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"135.82\" y1=\"645.43\" x2=\"59.05\" y2=\"643.98\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"145.82,645.62 135.92,640.43 135.73,650.43\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"170.21\" y1=\"639.60\" x2=\"365.26\" y2=\"532.47\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"374.02,527.65 362.85,528.08 367.66,536.85\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"957.62\" y1=\"636.08\" x2=\"1042.36\" y2=\"574.30\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1050.44,568.41 1039.42,570.26 1045.31,578.34\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"171.65\" y1=\"556.52\" x2=\"362.72\" y2=\"525.12\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"372.59,523.50 361.91,520.19 363.53,530.06\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"929.14\" y1=\"159.17\" x2=\"833.34\" y2=\"82.70\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"936.96,165.41 932.26,155.26 926.02,163.08\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"804.90\" y1=\"528.71\" x2=\"709.58\" y2=\"455.88\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"812.85,534.78 807.94,524.73 801.87,532.68\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"801.23\" y1=\"549.54\" x2=\"597.82\" y2=\"613.25\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"810.78,546.56 799.74,544.77 802.73,554.32\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"676.51\" y1=\"444.52\" x2=\"398.27\" y2=\"402.08\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"686.39,446.03 677.26,439.58 675.75,449.46\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"286.97\" y1=\"448.63\" x2=\"364.78\" y2=\"410.28\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"373.75,405.86 362.57,405.80 366.99,414.77\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"286.41\" y1=\"461.13\" x2=\"365.77\" y2=\"509.43\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"374.31,514.63 368.37,505.16 363.17,513.71\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><circle cx=\"158.82\" cy=\"356.50\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"158.82\" y=\"381.50\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">PAP</text><circle cx=\"699.24\" cy=\"171.39\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"699.24\" y=\"196.39\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HISTORY</text><circle cx=\"1160.95\" cy=\"339.48\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1160.95\" y=\"364.48\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">CO</text><circle cx=\"699.24\" cy=\"335.22\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"699.24\" y=\"360.22\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">TPR</text><circle cx=\"275.31\" cy=\"356.50\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"275.31\" y=\"381.50\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">PULMEMBOLUS</text><circle cx=\"1060.95\" cy=\"288.41\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"313.41\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">BP</text><circle cx=\"1060.95\" cy=\"472.46\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"497.46\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HRBP</text><circle cx=\"1060.95\" cy=\"642.67\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"667.67\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HREKG</text><circle cx=\"385.41\" cy=\"683.10\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"385.41\" y=\"708.10\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">EXPCO2</text><circle cx=\"46.05\" cy=\"730.97\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"46.05\" y=\"755.97\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">VENTMACH</text><circle cx=\"947.12\" cy=\"72.46\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"947.12\" y=\"97.46\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">LVEDVOLUME</text><circle cx=\"823.18\" cy=\"319.27\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"823.18\" y=\"344.27\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">ANAPHYLAXIS</text><circle cx=\"823.18\" cy=\"171.39\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"823.18\" y=\"196.39\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">LVFAILURE</text><circle cx=\"585.41\" cy=\"473.52\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"585.41\" y=\"498.52\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">PVSAT</text><circle cx=\"275.31\" cy=\"703.31\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"275.31\" y=\"728.31\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">MINVOL</text><circle cx=\"699.24\" cy=\"542.67\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"699.24\" y=\"567.67\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">INSUFFANESTH</text><circle cx=\"485.41\" cy=\"556.50\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"485.41\" y=\"581.50\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">VENTALV</text><circle cx=\"158.82\" cy=\"730.97\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"158.82\" y=\"755.97\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">MINVOLSET</text><circle cx=\"385.41\" cy=\"602.24\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"385.41\" y=\"627.24\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">VENTLUNG</text><circle cx=\"485.41\" cy=\"473.52\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"485.41\" y=\"498.52\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">FIO2</text><circle cx=\"947.12\" cy=\"559.69\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"947.12\" y=\"584.69\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HR</text><circle cx=\"158.82\" cy=\"645.86\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"158.82\" y=\"670.86\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">VENTTUBE</text><circle cx=\"46.05\" cy=\"643.73\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"46.05\" y=\"668.73\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">DISCONNECT</text><circle cx=\"947.12\" cy=\"643.73\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"947.12\" y=\"668.73\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">ERRCAUTER</text><circle cx=\"158.82\" cy=\"558.63\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"158.82\" y=\"583.63\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">KINKEDTUBE</text><circle cx=\"947.12\" cy=\"173.52\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"947.12\" y=\"198.52\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">STROKEVOLUME</text><circle cx=\"823.18\" cy=\"74.59\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"823.18\" y=\"99.59\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HYPOVOLEMIA</text><circle cx=\"947.12\" cy=\"465.01\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"947.12\" y=\"490.01\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">ERRLOWOUTPUT</text><circle cx=\"1060.95\" cy=\"112.88\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"137.88\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">PCWP</text><circle cx=\"823.18\" cy=\"542.67\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"823.18\" y=\"567.67\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">CATECHOL</text><circle cx=\"699.24\" cy=\"447.99\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"699.24\" y=\"472.99\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">SAO2</text><circle cx=\"275.31\" cy=\"454.37\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"275.31\" y=\"479.37\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">INTUBATION</text><circle cx=\"385.41\" cy=\"400.12\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"385.41\" y=\"425.12\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">SHUNT</text><circle cx=\"1060.95\" cy=\"32.03\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"57.03\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">CVP</text><circle cx=\"1060.95\" cy=\"560.76\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"585.76\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HRSAT</text><circle cx=\"585.41\" cy=\"617.14\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"585.41\" y=\"642.14\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">ARTCO2</text><circle cx=\"385.41\" cy=\"521.39\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"385.41\" y=\"546.39\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">PRESS</text></svg>"
      ],
      "text/plain": [
       "'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1207 763\" width=\"100%\" font-family=\"Inter, system-ui, sans-serif\"><rect width=\"1207\" height=\"763\" fill=\"#fafbfc\"/><line x1=\"171.82\" y1=\"356.50\" x2=\"262.31\" y2=\"356.50\" stroke=\"#e0982b\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><line x1=\"712.24\" y1=\"171.39\" x2=\"810.18\" y2=\"171.39\" stroke=\"#e0982b\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><line x1=\"1137.95\" y1=\"339.27\" x2=\"712.24\" y2=\"335.34\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1147.95,339.36 1137.99,334.27 1137.90,344.27\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1140.46\" y1=\"329.02\" x2=\"1072.52\" y2=\"294.33\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1149.37,333.57 1142.74,324.57 1138.19,333.47\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><path d=\"M 712.20 336.29 Q 885.10 350.50 1039.26 296.07\" fill=\"none\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1048.69,292.74 1037.59,291.36 1040.92,300.79\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"712.14\" y1=\"333.56\" x2=\"810.29\" y2=\"320.93\" stroke=\"#e0982b\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><line x1=\"705.91\" y1=\"346.38\" x2=\"811.38\" y2=\"522.93\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"816.51,531.51 815.68,520.36 807.09,525.49\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"287.39\" y1=\"361.29\" x2=\"364.03\" y2=\"391.65\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"373.33,395.33 365.87,387.00 362.19,396.29\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1052.05\" y1=\"309.62\" x2=\"952.15\" y2=\"547.70\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1055.92,300.40 1047.44,307.69 1056.66,311.56\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1044.76\" y1=\"272.08\" x2=\"956.27\" y2=\"182.76\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1051.80,279.18 1048.31,268.56 1041.21,275.60\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1042.69\" y1=\"486.45\" x2=\"957.44\" y2=\"551.78\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1050.63,480.37 1039.65,482.48 1045.73,490.42\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1038.00\" y1=\"470.96\" x2=\"960.09\" y2=\"465.86\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1047.97,471.61 1038.32,465.97 1037.67,475.95\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1042.36\" y1=\"629.12\" x2=\"957.62\" y2=\"567.35\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1050.44,635.01 1045.31,625.08 1039.42,633.16\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"1037.95\" y1=\"642.89\" x2=\"960.12\" y2=\"643.61\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1047.95,642.79 1037.90,637.89 1037.99,647.88\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"362.79\" y1=\"687.25\" x2=\"288.09\" y2=\"700.96\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"372.63,685.44 361.89,682.33 363.70,692.17\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"393.47\" y1=\"672.89\" x2=\"471.16\" y2=\"574.55\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"477.36,566.70 467.23,571.45 475.08,577.65\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"397.76\" y1=\"679.02\" x2=\"563.57\" y2=\"624.34\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"573.07,621.21 562.01,619.59 565.14,629.09\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"59.05\" y1=\"730.97\" x2=\"145.82\" y2=\"730.97\" stroke=\"#e0982b\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><line x1=\"56.43\" y1=\"723.14\" x2=\"140.46\" y2=\"659.72\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"148.44,653.69 137.45,655.73 143.47,663.71\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"929.14\" y1=\"86.81\" x2=\"833.34\" y2=\"163.28\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"936.96,80.57 926.02,82.90 932.26,90.71\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"924.12\" y1=\"72.85\" x2=\"836.18\" y2=\"74.36\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"934.12,72.68 924.03,67.85 924.21,77.85\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"959.37\" y1=\"76.81\" x2=\"1039.27\" y2=\"105.19\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1048.70,108.53 1040.95,100.47 1037.60,109.90\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"959.37\" y1=\"68.11\" x2=\"1039.27\" y2=\"39.73\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1048.70,36.38 1037.60,35.02 1040.95,44.44\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"836.18\" y1=\"171.62\" x2=\"924.12\" y2=\"173.13\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"934.12,173.30 924.21,168.13 924.03,178.13\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"567.71\" y1=\"488.21\" x2=\"495.42\" y2=\"548.20\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"575.41,481.82 564.52,484.36 570.91,492.06\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"562.41\" y1=\"473.52\" x2=\"498.41\" y2=\"473.52\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"572.41,473.52 562.41,468.52 562.41,478.52\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"598.10\" y1=\"470.68\" x2=\"676.80\" y2=\"453.02\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"686.56,450.83 675.71,448.14 677.90,457.90\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"284.89\" y1=\"694.52\" x2=\"368.47\" y2=\"617.80\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"375.84,611.04 365.09,614.11 371.85,621.48\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"254.68\" y1=\"693.14\" x2=\"170.48\" y2=\"651.61\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"263.65,697.56 256.89,688.65 252.47,697.62\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"260.88\" y1=\"685.39\" x2=\"166.97\" y2=\"568.75\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"267.16,693.18 264.78,682.26 256.99,688.53\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"712.24\" y1=\"542.67\" x2=\"800.18\" y2=\"542.67\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"810.18,542.67 800.18,537.67 800.18,547.67\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"464.50\" y1=\"566.07\" x2=\"397.24\" y2=\"596.84\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"473.59,561.91 462.42,561.52 466.58,570.61\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><path d=\"M 465.97 544.22 Q 386.04 493.74 287.56 458.73\" fill=\"none\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"474.42,549.56 468.64,539.99 463.30,548.45\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"496.53\" y1=\"563.24\" x2=\"565.75\" y2=\"605.21\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"574.30,610.40 568.34,600.94 563.16,609.49\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"362.83\" y1=\"606.59\" x2=\"171.58\" y2=\"643.40\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"372.65,604.70 361.88,601.68 363.77,611.50\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"362.83\" y1=\"597.90\" x2=\"171.58\" y2=\"561.08\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"372.65,599.79 363.77,592.99 361.88,602.81\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"371.68\" y1=\"583.80\" x2=\"283.07\" y2=\"464.80\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"377.65,591.82 375.69,580.81 367.67,586.78\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"398.38\" y1=\"603.21\" x2=\"562.48\" y2=\"615.43\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"572.45,616.17 562.85,610.44 562.11,620.42\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"924.33\" y1=\"556.56\" x2=\"836.06\" y2=\"544.44\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"934.24,557.92 925.01,551.61 923.65,561.52\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"960.12\" y1=\"559.81\" x2=\"1037.95\" y2=\"560.54\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1047.95,560.63 1037.99,555.54 1037.90,565.54\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"135.82\" y1=\"645.43\" x2=\"59.05\" y2=\"643.98\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"145.82,645.62 135.92,640.43 135.73,650.43\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"170.21\" y1=\"639.60\" x2=\"365.26\" y2=\"532.47\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"374.02,527.65 362.85,528.08 367.66,536.85\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"957.62\" y1=\"636.08\" x2=\"1042.36\" y2=\"574.30\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"1050.44,568.41 1039.42,570.26 1045.31,578.34\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"171.65\" y1=\"556.52\" x2=\"362.72\" y2=\"525.12\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"372.59,523.50 361.91,520.19 363.53,530.06\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"929.14\" y1=\"159.17\" x2=\"833.34\" y2=\"82.70\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"936.96,165.41 932.26,155.26 926.02,163.08\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"804.90\" y1=\"528.71\" x2=\"709.58\" y2=\"455.88\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"812.85,534.78 807.94,524.73 801.87,532.68\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"801.23\" y1=\"549.54\" x2=\"597.82\" y2=\"613.25\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"810.78,546.56 799.74,544.77 802.73,554.32\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"676.51\" y1=\"444.52\" x2=\"398.27\" y2=\"402.08\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"686.39,446.03 677.26,439.58 675.75,449.46\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"286.97\" y1=\"448.63\" x2=\"364.78\" y2=\"410.28\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"373.75,405.86 362.57,405.80 366.99,414.77\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><line x1=\"286.41\" y1=\"461.13\" x2=\"365.77\" y2=\"509.43\" stroke=\"#3a4658\" stroke-width=\"2.0\" stroke-linecap=\"round\"/><polygon points=\"374.31,514.63 368.37,505.16 363.17,513.71\" fill=\"#3a4658\" stroke-linejoin=\"round\"/><circle cx=\"158.82\" cy=\"356.50\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"158.82\" y=\"381.50\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">PAP</text><circle cx=\"699.24\" cy=\"171.39\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"699.24\" y=\"196.39\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HISTORY</text><circle cx=\"1160.95\" cy=\"339.48\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1160.95\" y=\"364.48\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">CO</text><circle cx=\"699.24\" cy=\"335.22\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"699.24\" y=\"360.22\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">TPR</text><circle cx=\"275.31\" cy=\"356.50\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"275.31\" y=\"381.50\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">PULMEMBOLUS</text><circle cx=\"1060.95\" cy=\"288.41\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"313.41\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">BP</text><circle cx=\"1060.95\" cy=\"472.46\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"497.46\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HRBP</text><circle cx=\"1060.95\" cy=\"642.67\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"667.67\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HREKG</text><circle cx=\"385.41\" cy=\"683.10\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"385.41\" y=\"708.10\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">EXPCO2</text><circle cx=\"46.05\" cy=\"730.97\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"46.05\" y=\"755.97\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">VENTMACH</text><circle cx=\"947.12\" cy=\"72.46\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"947.12\" y=\"97.46\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">LVEDVOLUME</text><circle cx=\"823.18\" cy=\"319.27\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"823.18\" y=\"344.27\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">ANAPHYLAXIS</text><circle cx=\"823.18\" cy=\"171.39\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"823.18\" y=\"196.39\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">LVFAILURE</text><circle cx=\"585.41\" cy=\"473.52\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"585.41\" y=\"498.52\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">PVSAT</text><circle cx=\"275.31\" cy=\"703.31\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"275.31\" y=\"728.31\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">MINVOL</text><circle cx=\"699.24\" cy=\"542.67\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"699.24\" y=\"567.67\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">INSUFFANESTH</text><circle cx=\"485.41\" cy=\"556.50\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"485.41\" y=\"581.50\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">VENTALV</text><circle cx=\"158.82\" cy=\"730.97\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"158.82\" y=\"755.97\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">MINVOLSET</text><circle cx=\"385.41\" cy=\"602.24\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"385.41\" y=\"627.24\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">VENTLUNG</text><circle cx=\"485.41\" cy=\"473.52\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"485.41\" y=\"498.52\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">FIO2</text><circle cx=\"947.12\" cy=\"559.69\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"947.12\" y=\"584.69\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HR</text><circle cx=\"158.82\" cy=\"645.86\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"158.82\" y=\"670.86\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">VENTTUBE</text><circle cx=\"46.05\" cy=\"643.73\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"46.05\" y=\"668.73\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">DISCONNECT</text><circle cx=\"947.12\" cy=\"643.73\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"947.12\" y=\"668.73\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">ERRCAUTER</text><circle cx=\"158.82\" cy=\"558.63\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"158.82\" y=\"583.63\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">KINKEDTUBE</text><circle cx=\"947.12\" cy=\"173.52\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"947.12\" y=\"198.52\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">STROKEVOLUME</text><circle cx=\"823.18\" cy=\"74.59\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"823.18\" y=\"99.59\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HYPOVOLEMIA</text><circle cx=\"947.12\" cy=\"465.01\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"947.12\" y=\"490.01\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">ERRLOWOUTPUT</text><circle cx=\"1060.95\" cy=\"112.88\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"137.88\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">PCWP</text><circle cx=\"823.18\" cy=\"542.67\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"823.18\" y=\"567.67\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">CATECHOL</text><circle cx=\"699.24\" cy=\"447.99\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"699.24\" y=\"472.99\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">SAO2</text><circle cx=\"275.31\" cy=\"454.37\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"275.31\" y=\"479.37\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">INTUBATION</text><circle cx=\"385.41\" cy=\"400.12\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"385.41\" y=\"425.12\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">SHUNT</text><circle cx=\"1060.95\" cy=\"32.03\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"57.03\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">CVP</text><circle cx=\"1060.95\" cy=\"560.76\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"1060.95\" y=\"585.76\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">HRSAT</text><circle cx=\"585.41\" cy=\"617.14\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"585.41\" y=\"642.14\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">ARTCO2</text><circle cx=\"385.41\" cy=\"521.39\" r=\"13.00\" fill=\"#ffffff\" stroke=\"#182233\" stroke-width=\"1.8\"/><text x=\"385.41\" y=\"546.39\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"600\" fill=\"#5c6675\">PRESS</text></svg>'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "passing = sweep[sweep.verdict == \"not rejected\"]\n",
    "sparsest = passing.loc[passing.edges.idxmin(), \"penalty_discount\"]\n",
    "print(\"sparsest graph that passes: penalty_discount\", sparsest)\n",
    "andrey.viz.draw(fits[sparsest].structure)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "markov_check-16",
   "metadata": {},
   "source": [
    "## PC: no graph passes\n",
    "\n",
    "The same sweep over PC's `alpha`, the level of its independence tests. PC returns a CPDAG, which\n",
    "the check reads through a DAG of its class; a graph with no consistent DAG cannot be checked, and\n",
    "`markov_check` raises `ValueError`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "markov_check-17",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>alpha</th>\n",
       "      <th>edges</th>\n",
       "      <th>errors</th>\n",
       "      <th>uniformity p</th>\n",
       "      <th>verdict</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.001</td>\n",
       "      <td>35</td>\n",
       "      <td>25</td>\n",
       "      <td>0.0</td>\n",
       "      <td>rejected</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.010</td>\n",
       "      <td>36</td>\n",
       "      <td>24</td>\n",
       "      <td>0.0</td>\n",
       "      <td>rejected</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.050</td>\n",
       "      <td>42</td>\n",
       "      <td>24</td>\n",
       "      <td>0.0</td>\n",
       "      <td>rejected</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.100</td>\n",
       "      <td>43</td>\n",
       "      <td>25</td>\n",
       "      <td>0.0</td>\n",
       "      <td>rejected</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.300</td>\n",
       "      <td>52</td>\n",
       "      <td>31</td>\n",
       "      <td>NaN</td>\n",
       "      <td>no DAG to check</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   alpha  edges  errors  uniformity p          verdict\n",
       "0  0.001     35      25           0.0         rejected\n",
       "1  0.010     36      24           0.0         rejected\n",
       "2  0.050     42      24           0.0         rejected\n",
       "3  0.100     43      25           0.0         rejected\n",
       "4  0.300     52      31           NaN  no DAG to check"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rows = []\n",
    "for alpha in (0.001, 0.01, 0.05, 0.1, 0.3):\n",
    "    fit = andrey.pc(learn, alpha=alpha)\n",
    "    row = {\n",
    "        \"alpha\": alpha,\n",
    "        \"edges\": len(fit.structure.oriented_edges()),\n",
    "        \"errors\": shd(fit.structure, true_cpdag),\n",
    "    }\n",
    "    try:\n",
    "        check = andrey.markov_check(fit, held)\n",
    "        row[\"uniformity p\"] = round(check.uniformity_p_value, 3)\n",
    "        row[\"verdict\"] = \"not rejected\" if check.passed else \"rejected\"\n",
    "    except ValueError:\n",
    "        row[\"uniformity p\"], row[\"verdict\"] = None, \"no DAG to check\"\n",
    "    rows.append(row)\n",
    "pd.DataFrame(rows)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "markov_check-18",
   "metadata": {},
   "source": [
    "At every `alpha` the data reject the graph PC returns, or the graph has no DAG to check, so there\n",
    "is nothing to choose from. This is a finding about PC on these data and this sample size: PC's\n",
    "graphs differ from the true CPDAG by many more errors than GES's, and the check agrees that they do\n",
    "not fit the data. It does not say which edges to change; the smallest p-values in `table()` show\n",
    "where to look. `andrey markov-check` runs the same check from the shell."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "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.14.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
