Skip to content
Snippets Groups Projects
4_Feature_Analyses.ipynb 206 KiB
Newer Older
Shengpu Tang (tangsp)'s avatar
Shengpu Tang (tangsp) committed
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import random\n",
    "import scipy.stats\n",
    "import pickle, os, time\n",
    "import itertools\n",
    "from datetime import datetime, timedelta\n",
    "from collections import Counter, defaultdict, namedtuple\n",
    "from PIL import Image\n",
    "import yaml\n",
    "from tqdm import tqdm\n",
    "\n",
    "from sklearn import preprocessing, model_selection, metrics, utils\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from tqdm import tqdm\n",
    "from joblib import Parallel, delayed\n",
    "from sklearn.base import clone\n",
    "\n",
    "import seaborn as sns\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "data_dir = '/data/GVHD/'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "%config InlineBackend.figure_format = 'svg'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Helper functions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Model training"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def train_model(Xtr, ytr):\n",
    "    np.random.seed(42)\n",
    "    random.seed(42)\n",
    "    \n",
    "    # Specify hyperparameters and cv parameters\n",
    "    base_estimator = LogisticRegression(\n",
    "        penalty='l2', \n",
    "        class_weight='balanced', \n",
    "        solver='liblinear'\n",
    "    )\n",
    "    param_grid = {\n",
    "        'C': [10. ** n for n in range(-6, 7)],\n",
    "        'penalty': ['l2'],\n",
    "    }\n",
    "    \n",
    "    cv_splits, cv_repeat = 5, 20\n",
    "    cv = model_selection.RepeatedStratifiedKFold(cv_splits, cv_repeat, random_state=0)\n",
    "    clf = model_selection.GridSearchCV(\n",
    "        clone(base_estimator), param_grid, \n",
    "        cv=cv, scoring='roc_auc', iid=False, n_jobs=5,\n",
    "    )\n",
    "    clf.fit(Xtr, ytr)\n",
    "    return clf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Evaluation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def boostrap_func_all(i, y_true, y_prob, threshold):\n",
    "    fpr, tpr, thresholds = metrics.roc_curve(y_true, y_prob)\n",
    "    y_true_b, y_prob_b = utils.resample(y_true, y_prob, replace=True, random_state=i)\n",
    "    y_pred_b = (y_prob_b > threshold)\n",
    "    tpr_cutoff = metrics.recall_score(y_true_b, y_pred_b)\n",
    "    idx = (np.abs(tpr - tpr_cutoff)).argmin()\n",
    "    \n",
    "    return (\n",
    "        metrics.roc_auc_score(y_true_b, y_prob_b), # AUC\n",
    "        tpr[idx], # sensitivity\n",
    "        1-fpr[idx], # specificity\n",
    "        metrics.precision_score(y_true_b, y_pred_b), # positive predictive value\n",
    "    )\n",
    "\n",
    "def boostrap_func_confusion(i, y_true, y_prob, threshold):\n",
    "    fpr, tpr, thresholds = metrics.roc_curve(y_true, y_prob)\n",
    "    y_true_b, y_prob_b = utils.resample(y_true, y_prob, replace=True, random_state=i)\n",
    "    y_pred_b = (y_prob_b > threshold)\n",
    "    tpr_cutoff = metrics.recall_score(y_true_b, y_pred_b)\n",
    "    idx = (np.abs(tpr - tpr_cutoff)).argmin()\n",
    "    \n",
    "    return metrics.confusion_matrix(y_true_b, y_pred_b).ravel()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def evaluate_model(clf, Xte, yte, Xtr=None, threshold_p=55, verbose=True):\n",
    "    y_true = yte\n",
    "    y_score = clf.decision_function(Xte)\n",
    "    y_prob = clf.predict_proba(Xte)[:,1]\n",
    "    \n",
    "    fpr, tpr, thresholds = metrics.roc_curve(y_true, y_score)\n",
    "    test_auc = metrics.roc_auc_score(y_true, y_score)\n",
    "    \n",
    "    # Picking a risk threshold based on training set if possible\n",
    "    if Xtr is not None:\n",
    "        if verbose: print('Risk threshold based on train set')\n",
    "        threshold = np.percentile(clf.predict_proba(Xtr)[:,1], threshold_p)\n",
    "    else:\n",
    "        if verbose: print('Risk threshold based on test set')\n",
    "        threshold = np.percentile(y_score, 55)\n",
    "    if verbose: print('p_Threshold', threshold)\n",
    "    \n",
    "    if verbose: print()\n",
    "    if verbose: print('Confusion matrix (95%CI lower, upper)')\n",
    "    y_pred = (y_prob > threshold)\n",
    "    conf_mat = metrics.confusion_matrix(y_true, y_pred)\n",
    "    if verbose: print(conf_mat) # Rows: actual 0, actual 1; Cols: predicted 0, predicted 1\n",
    "    \n",
    "    confmats = [boostrap_func_confusion(i, y_true, y_prob, threshold) for i in range(1000)]\n",
    "    confmats_ = np.asarray(confmats)\n",
    "    if verbose: print(np.percentile(confmats_, 2.5, axis=0).reshape(2,2))\n",
    "    if verbose: print(np.percentile(confmats_, 97.5, axis=0).reshape(2,2))\n",
    "\n",
    "    if verbose: print()\n",
    "    if verbose: print('scores')\n",
    "    tpr_ = metrics.recall_score(y_true, y_pred)\n",
    "    idx = (np.abs(tpr - tpr_)).argmin()\n",
    "    if verbose: print('AUROC={:.3f}'.format(test_auc))\n",
    "    if verbose: print('TPR={:.3f}, FPR={:.3f} PPV={:.3f}'.format(\n",
    "        tpr[idx], fpr[idx],\n",
    "        metrics.precision_score(y_true, y_pred)))\n",
    "\n",
    "    if verbose: print()\n",
    "    if verbose: print('scores (95%CI lower, upper)')\n",
    "    auc_scores, sensitivities, specificities, ppvs = zip(*[boostrap_func_all(i, y_true, y_prob, threshold) for i in range(1000)])\n",
    "    if verbose: print('Test AUC {:.3f} ({:.3f}, {:.3f})'.format(np.median(auc_scores), np.percentile(auc_scores, 2.5), np.percentile(auc_scores, 97.5)))\n",
    "    if verbose: print('Test AUC {:.3f} ± {:.3f}'.format(np.mean(auc_scores), np.std(auc_scores)))\n",
    "    if verbose: print('sens.\\t {:.1%} ({:.1%}, {:.1%})'.format(np.mean(sensitivities), np.percentile(sensitivities, 2.5), np.percentile(sensitivities, 97.5)))\n",
    "    if verbose: print('spec.\\t {:.1%} ({:.1%}, {:.1%})'.format(np.mean(specificities), np.percentile(specificities, 2.5), np.percentile(specificities, 97.5)))\n",
    "    if verbose: print('prec.\\t {:.1%} ({:.1%}, {:.1%})'.format(np.mean(ppvs), np.percentile(ppvs, 2.5), np.percentile(ppvs, 97.5)))\n",
    "    \n",
    "    return test_auc, auc_scores, fpr, tpr"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Data loading"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "pop = pd.read_csv(data_dir + 'population/d10_with_vitals.csv').set_index('BMT_ID')\n",
    "extracted_features = pd.read_csv('data/ts_features.csv', index_col='id')\n",
    "df_label = pop.join(pd.read_csv(data_dir + 'prep/label.csv', index_col='BMT_ID'), how='left')\n",
    "df_features = pd.read_csv('data/df_features.csv', index_col='id')\n",
    "feature_names = df_features.columns"
   ]
  },
  {
   "cell_type": "code",
Shengpu Tang (tangsp)'s avatar
Shengpu Tang (tangsp) committed
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "with np.load('data/Xy.npz') as f:\n",
    "    X = f['X']\n",
    "    y = f['y']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Temporal split"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "split_date = 201701001\n",
    "split_idx = -85\n",
    "\n",
    "assert (pop[:split_idx].index < split_date).all()\n",
    "assert (pop[split_idx:].index >= split_date).all()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "Xtr_all, Xte_all = X[:split_idx], X[split_idx:]\n",
    "ytr, yte = y[:split_idx], y[split_idx:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Main model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "Xtr, Xte = Xtr_all, Xte_all\n",
    "clf = train_model(Xtr, ytr)\n",
    "auc_main, auc_scores_main, fpr_main, tpr_main = evaluate_model(clf, Xte, yte, Xtr, 55, verbose=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'C': 0.01, 'penalty': 'l2'}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf.best_params_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Sensitivity Analyses"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Omitting specific subsets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_corr = df_features.corr().abs()\n",
    "np.fill_diagonal(df_corr.values, 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "feature_groups = []\n",
    "feature_groups_desc = []\n",
    "for variable, stat in itertools.product(\n",
    "    ['Temp', 'HR', 'RR', 'SysBP', 'DiaBP', 'SpO2'],\n",
    "    ['__mean_', 'slope', 'sample_entropy', 'abs', 'angle']\n",
    "):\n",
    "    to_drop = [i for i, name in enumerate(feature_names) if name.startswith(variable) and stat in name]\n",
    "    feature_groups.append(to_drop)\n",
    "    feature_groups_desc.append((variable, stat))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_corr_group = []\n",
    "for (i1, g1), (i2, g2) in itertools.product(enumerate(feature_groups), enumerate(feature_groups)):\n",
    "#     print(i1,i2)\n",
    "#     if i1 < i2:\n",
    "    if i1 != i2:\n",
    "        co = df_corr.iloc[g1, g2].max().max()\n",
    "        df_corr_group.append((i1,i2,co))\n",
    "\n",
    "df_corr_group = pd.DataFrame(df_corr_group)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x7fb1504b2550>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"248.518125pt\" version=\"1.1\" viewBox=\"0 0 375.2875 248.518125\" width=\"375.2875pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 248.518125 \n",
       "L 375.2875 248.518125 \n",
       "L 375.2875 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 33.2875 224.64 \n",
       "L 368.0875 224.64 \n",
       "L 368.0875 7.2 \n",
       "L 33.2875 7.2 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path clip-path=\"url(#pdd56055091)\" d=\"M 48.505682 224.64 \n",
       "L 78.942045 224.64 \n",
       "L 78.942045 17.554286 \n",
       "L 48.505682 17.554286 \n",
       "z\n",
       "\" style=\"fill:#1f77b4;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path clip-path=\"url(#pdd56055091)\" d=\"M 78.942045 224.64 \n",
       "L 109.378409 224.64 \n",
       "L 109.378409 146.198442 \n",
       "L 78.942045 146.198442 \n",
       "z\n",
       "\" style=\"fill:#1f77b4;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path clip-path=\"url(#pdd56055091)\" d=\"M 109.378409 224.64 \n",
       "L 139.814773 224.64 \n",
       "L 139.814773 208.951688 \n",
       "L 109.378409 208.951688 \n",
       "z\n",
       "\" style=\"fill:#1f77b4;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path clip-path=\"url(#pdd56055091)\" d=\"M 139.814773 224.64 \n",
       "L 170.251136 224.64 \n",
       "L 170.251136 212.089351 \n",
       "L 139.814773 212.089351 \n",
       "z\n",
       "\" style=\"fill:#1f77b4;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_7\">\n",
       "    <path clip-path=\"url(#pdd56055091)\" d=\"M 170.251136 224.64 \n",
       "L 200.6875 224.64 \n",
       "L 200.6875 219.933506 \n",
       "L 170.251136 219.933506 \n",
       "z\n",
       "\" style=\"fill:#1f77b4;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_8\">\n",
       "    <path clip-path=\"url(#pdd56055091)\" d=\"M 200.6875 224.64 \n",
       "L 231.123864 224.64 \n",
       "L 231.123864 217.58026 \n",
       "L 200.6875 217.58026 \n",
       "z\n",
       "\" style=\"fill:#1f77b4;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_9\">\n",
       "    <path clip-path=\"url(#pdd56055091)\" d=\"M 231.123864 224.64 \n",
       "L 261.560227 224.64 \n",
       "L 261.560227 218.364675 \n",
       "L 231.123864 218.364675 \n",
       "z\n",
       "\" style=\"fill:#1f77b4;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_10\">\n",
       "    <path clip-path=\"url(#pdd56055091)\" d=\"M 261.560227 224.64 \n",
       "L 291.996591 224.64 \n",
       "L 291.996591 219.933506 \n",
       "L 261.560227 219.933506 \n",
       "z\n",
       "\" style=\"fill:#1f77b4;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_11\">\n",
       "    <path clip-path=\"url(#pdd56055091)\" d=\"M 291.996591 224.64 \n",
       "L 322.432955 224.64 \n",
       "L 322.432955 222.286753 \n",
       "L 291.996591 222.286753 \n",
       "z\n",
       "\" style=\"fill:#1f77b4;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_12\">\n",
       "    <path clip-path=\"url(#pdd56055091)\" d=\"M 322.432955 224.64 \n",
       "L 352.869318 224.64 \n",
       "L 352.869318 222.286753 \n",
       "L 322.432955 222.286753 \n",
       "z\n",
       "\" style=\"fill:#1f77b4;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 77.763877 224.64 \n",
       "L 77.763877 7.2 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" id=\"m0bdfaba779\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"77.763877\" xlink:href=\"#m0bdfaba779\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0.2 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 66.40625 \n",
       "Q 24.171875 66.40625 20.328125 58.90625 \n",
       "Q 16.5 51.421875 16.5 36.375 \n",
       "Q 16.5 21.390625 20.328125 13.890625 \n",
       "Q 24.171875 6.390625 31.78125 6.390625 \n",
       "Q 39.453125 6.390625 43.28125 13.890625 \n",
       "Q 47.125 21.390625 47.125 36.375 \n",
       "Q 47.125 51.421875 43.28125 58.90625 \n",
       "Q 39.453125 66.40625 31.78125 66.40625 \n",
       "z\n",
       "M 31.78125 74.21875 \n",
       "Q 44.046875 74.21875 50.515625 64.515625 \n",
       "Q 56.984375 54.828125 56.984375 36.375 \n",
       "Q 56.984375 17.96875 50.515625 8.265625 \n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \n",
       "Q 6.59375 17.96875 6.59375 36.375 \n",
       "Q 6.59375 54.828125 13.0625 64.515625 \n",
       "Q 19.53125 74.21875 31.78125 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-48\"/>\n",
       "       <path d=\"M 10.6875 12.40625 \n",
       "L 21 12.40625 \n",
       "L 21 0 \n",
       "L 10.6875 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-46\"/>\n",
       "       <path d=\"M 19.1875 8.296875 \n",
       "L 53.609375 8.296875 \n",
       "L 53.609375 0 \n",
       "L 7.328125 0 \n",
       "L 7.328125 8.296875 \n",
       "Q 12.9375 14.109375 22.625 23.890625 \n",
       "Q 32.328125 33.6875 34.8125 36.53125 \n",
       "Q 39.546875 41.84375 41.421875 45.53125 \n",
       "Q 43.3125 49.21875 43.3125 52.78125 \n",
       "Q 43.3125 58.59375 39.234375 62.25 \n",
       "Q 35.15625 65.921875 28.609375 65.921875 \n",
       "Q 23.96875 65.921875 18.8125 64.3125 \n",
       "Q 13.671875 62.703125 7.8125 59.421875 \n",
       "L 7.8125 69.390625 \n",
       "Q 13.765625 71.78125 18.9375 73 \n",
       "Q 24.125 74.21875 28.421875 74.21875 \n",
       "Q 39.75 74.21875 46.484375 68.546875 \n",
       "Q 53.21875 62.890625 53.21875 53.421875 \n",
       "Q 53.21875 48.921875 51.53125 44.890625 \n",
       "Q 49.859375 40.875 45.40625 35.40625 \n",
       "Q 44.1875 33.984375 37.640625 27.21875 \n",
       "Q 31.109375 20.453125 19.1875 8.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-50\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(69.812314 239.238437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-50\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 123.604551 224.64 \n",
       "L 123.604551 7.2 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"123.604551\" xlink:href=\"#m0bdfaba779\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 0.3 -->\n",
       "      <defs>\n",
       "       <path d=\"M 40.578125 39.3125 \n",
       "Q 47.65625 37.796875 51.625 33 \n",
       "Q 55.609375 28.21875 55.609375 21.1875 \n",
       "Q 55.609375 10.40625 48.1875 4.484375 \n",
       "Q 40.765625 -1.421875 27.09375 -1.421875 \n",
       "Q 22.515625 -1.421875 17.65625 -0.515625 \n",
       "Q 12.796875 0.390625 7.625 2.203125 \n",
       "L 7.625 11.71875 \n",
       "Q 11.71875 9.328125 16.59375 8.109375 \n",
       "Q 21.484375 6.890625 26.8125 6.890625 \n",
       "Q 36.078125 6.890625 40.9375 10.546875 \n",
       "Q 45.796875 14.203125 45.796875 21.1875 \n",
       "Q 45.796875 27.640625 41.28125 31.265625 \n",
       "Q 36.765625 34.90625 28.71875 34.90625 \n",
       "L 20.21875 34.90625 \n",
       "L 20.21875 43.015625 \n",
       "L 29.109375 43.015625 \n",
       "Q 36.375 43.015625 40.234375 45.921875 \n",
       "Q 44.09375 48.828125 44.09375 54.296875 \n",
       "Q 44.09375 59.90625 40.109375 62.90625 \n",
       "Q 36.140625 65.921875 28.71875 65.921875 \n",
       "Q 24.65625 65.921875 20.015625 65.03125 \n",
       "Q 15.375 64.15625 9.8125 62.3125 \n",
       "L 9.8125 71.09375 \n",
       "Q 15.4375 72.65625 20.34375 73.4375 \n",
       "Q 25.25 74.21875 29.59375 74.21875 \n",
       "Q 40.828125 74.21875 47.359375 69.109375 \n",
       "Q 53.90625 64.015625 53.90625 55.328125 \n",
       "Q 53.90625 49.265625 50.4375 45.09375 \n",
       "Q 46.96875 40.921875 40.578125 39.3125 \n",
       "z\n",
       "\" id=\"DejaVuSans-51\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(115.652989 239.238437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-51\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 169.445226 224.64 \n",
       "L 169.445226 7.2 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"169.445226\" xlink:href=\"#m0bdfaba779\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 0.4 -->\n",
       "      <defs>\n",
       "       <path d=\"M 37.796875 64.3125 \n",
       "L 12.890625 25.390625 \n",
       "L 37.796875 25.390625 \n",
       "z\n",
       "M 35.203125 72.90625 \n",
       "L 47.609375 72.90625 \n",
       "L 47.609375 25.390625 \n",
       "L 58.015625 25.390625 \n",
       "L 58.015625 17.1875 \n",
       "L 47.609375 17.1875 \n",
       "L 47.609375 0 \n",
       "L 37.796875 0 \n",
       "L 37.796875 17.1875 \n",
       "L 4.890625 17.1875 \n",
       "L 4.890625 26.703125 \n",
       "z\n",
       "\" id=\"DejaVuSans-52\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(161.493664 239.238437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-52\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 215.285901 224.64 \n",
       "L 215.285901 7.2 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"215.285901\" xlink:href=\"#m0bdfaba779\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 0.5 -->\n",
       "      <defs>\n",
       "       <path d=\"M 10.796875 72.90625 \n",
       "L 49.515625 72.90625 \n",
       "L 49.515625 64.59375 \n",
       "L 19.828125 64.59375 \n",
       "L 19.828125 46.734375 \n",
       "Q 21.96875 47.46875 24.109375 47.828125 \n",
       "Q 26.265625 48.1875 28.421875 48.1875 \n",
       "Q 40.625 48.1875 47.75 41.5 \n",
       "Q 54.890625 34.8125 54.890625 23.390625 \n",
       "Q 54.890625 11.625 47.5625 5.09375 \n",
       "Q 40.234375 -1.421875 26.90625 -1.421875 \n",
       "Q 22.3125 -1.421875 17.546875 -0.640625 \n",
       "Q 12.796875 0.140625 7.71875 1.703125 \n",
       "L 7.71875 11.625 \n",
       "Q 12.109375 9.234375 16.796875 8.0625 \n",
       "Q 21.484375 6.890625 26.703125 6.890625 \n",
       "Q 35.15625 6.890625 40.078125 11.328125 \n",
       "Q 45.015625 15.765625 45.015625 23.390625 \n",
       "Q 45.015625 31 40.078125 35.4375 \n",
       "Q 35.15625 39.890625 26.703125 39.890625 \n",
       "Q 22.75 39.890625 18.8125 39.015625 \n",
       "Q 14.890625 38.140625 10.796875 36.28125 \n",
       "z\n",
       "\" id=\"DejaVuSans-53\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(207.334339 239.238437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 261.126576 224.64 \n",
       "L 261.126576 7.2 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"261.126576\" xlink:href=\"#m0bdfaba779\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 0.6 -->\n",
       "      <defs>\n",
       "       <path d=\"M 33.015625 40.375 \n",
       "Q 26.375 40.375 22.484375 35.828125 \n",
       "Q 18.609375 31.296875 18.609375 23.390625 \n",
       "Q 18.609375 15.53125 22.484375 10.953125 \n",
       "Q 26.375 6.390625 33.015625 6.390625 \n",
       "Q 39.65625 6.390625 43.53125 10.953125 \n",
       "Q 47.40625 15.53125 47.40625 23.390625 \n",
       "Q 47.40625 31.296875 43.53125 35.828125 \n",
       "Q 39.65625 40.375 33.015625 40.375 \n",
       "z\n",
       "M 52.59375 71.296875 \n",
       "L 52.59375 62.3125 \n",
       "Q 48.875 64.0625 45.09375 64.984375 \n",
       "Q 41.3125 65.921875 37.59375 65.921875 \n",
       "Q 27.828125 65.921875 22.671875 59.328125 \n",
       "Q 17.53125 52.734375 16.796875 39.40625 \n",
       "Q 19.671875 43.65625 24.015625 45.921875 \n",
       "Q 28.375 48.1875 33.59375 48.1875 \n",
       "Q 44.578125 48.1875 50.953125 41.515625 \n",
       "Q 57.328125 34.859375 57.328125 23.390625 \n",
       "Q 57.328125 12.15625 50.6875 5.359375 \n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \n",
       "Q 6.984375 17.96875 6.984375 36.375 \n",
       "Q 6.984375 53.65625 15.1875 63.9375 \n",
       "Q 23.390625 74.21875 37.203125 74.21875 \n",
       "Q 40.921875 74.21875 44.703125 73.484375 \n",
       "Q 48.484375 72.75 52.59375 71.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-54\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(253.175014 239.238437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-54\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 306.967251 224.64 \n",
       "L 306.967251 7.2 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"306.967251\" xlink:href=\"#m0bdfaba779\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 0.7 -->\n",
       "      <defs>\n",
       "       <path d=\"M 8.203125 72.90625 \n",
       "L 55.078125 72.90625 \n",
       "L 55.078125 68.703125 \n",
       "L 28.609375 0 \n",
       "L 18.3125 0 \n",
       "L 43.21875 64.59375 \n",
       "L 8.203125 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-55\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(299.015689 239.238437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-55\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 352.807926 224.64 \n",
       "L 352.807926 7.2 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_14\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"352.807926\" xlink:href=\"#m0bdfaba779\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 0.8 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 34.625 \n",
       "Q 24.75 34.625 20.71875 30.859375 \n",
       "Q 16.703125 27.09375 16.703125 20.515625 \n",
       "Q 16.703125 13.921875 20.71875 10.15625 \n",
       "Q 24.75 6.390625 31.78125 6.390625 \n",
       "Q 38.8125 6.390625 42.859375 10.171875 \n",
       "Q 46.921875 13.96875 46.921875 20.515625 \n",
       "Q 46.921875 27.09375 42.890625 30.859375 \n",
       "Q 38.875 34.625 31.78125 34.625 \n",
       "z\n",
       "M 21.921875 38.8125 \n",
       "Q 15.578125 40.375 12.03125 44.71875 \n",
       "Q 8.5 49.078125 8.5 55.328125 \n",
       "Q 8.5 64.0625 14.71875 69.140625 \n",
       "Q 20.953125 74.21875 31.78125 74.21875 \n",
       "Q 42.671875 74.21875 48.875 69.140625 \n",
       "Q 55.078125 64.0625 55.078125 55.328125 \n",
       "Q 55.078125 49.078125 51.53125 44.71875 \n",
       "Q 48 40.375 41.703125 38.8125 \n",
       "Q 48.828125 37.15625 52.796875 32.3125 \n",
       "Q 56.78125 27.484375 56.78125 20.515625 \n",
       "Q 56.78125 9.90625 50.3125 4.234375 \n",
       "Q 43.84375 -1.421875 31.78125 -1.421875 \n",
       "Q 19.734375 -1.421875 13.25 4.234375 \n",
       "Q 6.78125 9.90625 6.78125 20.515625 \n",
       "Q 6.78125 27.484375 10.78125 32.3125 \n",
       "Q 14.796875 37.15625 21.921875 38.8125 \n",
       "z\n",
       "M 18.3125 54.390625 \n",
       "Q 18.3125 48.734375 21.84375 45.5625 \n",
       "Q 25.390625 42.390625 31.78125 42.390625 \n",
       "Q 38.140625 42.390625 41.71875 45.5625 \n",
       "Q 45.3125 48.734375 45.3125 54.390625 \n",
       "Q 45.3125 60.0625 41.71875 63.234375 \n",
       "Q 38.140625 66.40625 31.78125 66.40625 \n",
       "Q 25.390625 66.40625 21.84375 63.234375 \n",
       "Q 18.3125 60.0625 18.3125 54.390625 \n",
       "z\n",
       "\" id=\"DejaVuSans-56\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(344.856364 239.238437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-56\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 33.2875 224.64 \n",
       "L 368.0875 224.64 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_16\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" id=\"m6a7cf5cbb5\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"33.2875\" xlink:href=\"#m6a7cf5cbb5\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(19.925 228.439219)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 33.2875 185.419221 \n",
       "L 368.0875 185.419221 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_18\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"33.2875\" xlink:href=\"#m6a7cf5cbb5\" y=\"185.419221\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 100 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.40625 8.296875 \n",
       "L 28.515625 8.296875 \n",
       "L 28.515625 63.921875 \n",
       "L 10.984375 60.40625 \n",
       "L 10.984375 69.390625 \n",
       "L 28.421875 72.90625 \n",
       "L 38.28125 72.90625 \n",
       "L 38.28125 8.296875 \n",
       "L 54.390625 8.296875 \n",
       "L 54.390625 0 \n",
       "L 12.40625 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-49\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(7.2 189.21844)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 33.2875 146.198442 \n",
       "L 368.0875 146.198442 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_20\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"33.2875\" xlink:href=\"#m6a7cf5cbb5\" y=\"146.198442\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 200 -->\n",
       "      <g transform=\"translate(7.2 149.99766)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 33.2875 106.977662 \n",
       "L 368.0875 106.977662 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_22\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"33.2875\" xlink:href=\"#m6a7cf5cbb5\" y=\"106.977662\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 300 -->\n",
       "      <g transform=\"translate(7.2 110.776881)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-51\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_23\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 33.2875 67.756883 \n",
       "L 368.0875 67.756883 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_24\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"33.2875\" xlink:href=\"#m6a7cf5cbb5\" y=\"67.756883\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 400 -->\n",
       "      <g transform=\"translate(7.2 71.556102)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-52\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_25\">\n",
       "      <path clip-path=\"url(#pdd56055091)\" d=\"M 33.2875 28.536104 \n",
       "L 368.0875 28.536104 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_26\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"33.2875\" xlink:href=\"#m6a7cf5cbb5\" y=\"28.536104\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 500 -->\n",
       "      <g transform=\"translate(7.2 32.335323)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-53\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_13\">\n",
       "    <path d=\"M 33.2875 224.64 \n",
       "L 33.2875 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_14\">\n",
       "    <path d=\"M 368.0875 224.64 \n",
       "L 368.0875 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_15\">\n",
       "    <path d=\"M 33.2875 224.64 \n",
       "L 368.0875 224.64 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_16\">\n",
       "    <path d=\"M 33.2875 7.2 \n",
       "L 368.0875 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pdd56055091\">\n",
       "   <rect height=\"217.44\" width=\"334.8\" x=\"33.2875\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "pd.DataFrame(df_corr_group)[2].hist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "from collections import defaultdict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "grouped_groups = defaultdict(list)\n",
    "for it, row in df_corr_group[df_corr_group[2] > 0.6].iterrows():\n",
    "    grouped_groups[int(row[0])].append(int(row[1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "grouped_groups_ = []\n",
    "for i, g in grouped_groups.items():\n",
    "    found = False\n",
    "    for gg in grouped_groups_:\n",
    "        if i in gg:\n",
    "            found = True\n",
    "            gg = gg | set(g)\n",
    "    if not found:\n",
    "        grouped_groups_.append(set(g + [i]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{1, 3, 4}, {6, 8}, {10, 12}, {15, 20}, {16, 19}, {21, 24}, {25, 26, 27, 28}]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped_groups_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Temp __mean_ 632\n",
      "Test AUC: 0.662 (0.539, 0.784)\n",
      "Test AUC: 0.662 ± 0.064\n",
      "Temp slope 592\n",
      "Test AUC: 0.626 (0.500, 0.752)\n",
      "Test AUC: 0.627 ± 0.066\n",
      "Temp sample_entropy 632\n",
      "Test AUC: 0.662 (0.538, 0.788)\n",
      "Test AUC: 0.662 ± 0.063\n",
      "Temp abs 592\n",
      "Test AUC: 0.626 (0.500, 0.752)\n",
      "Test AUC: 0.627 ± 0.066\n",
      "Temp angle 592\n",
      "Test AUC: 0.626 (0.500, 0.752)\n",
      "Test AUC: 0.627 ± 0.066\n",
      "HR __mean_ 632\n",
      "Test AUC: 0.651 (0.534, 0.774)\n",
      "Test AUC: 0.651 ± 0.063\n",
      "HR slope 612\n",
      "Test AUC: 0.666 (0.545, 0.784)\n",
      "Test AUC: 0.665 ± 0.062\n",
      "HR sample_entropy 632\n",
      "Test AUC: 0.655 (0.531, 0.779)\n",
      "Test AUC: 0.654 ± 0.064\n",
      "HR abs 612\n",
      "Test AUC: 0.666 (0.545, 0.784)\n",
      "Test AUC: 0.665 ± 0.062\n",
      "HR angle 632\n",
      "Test AUC: 0.657 (0.529, 0.779)\n",
      "Test AUC: 0.657 ± 0.064\n",
      "RR __mean_ 612\n",
      "Test AUC: 0.634 (0.508, 0.758)\n",
      "Test AUC: 0.633 ± 0.065\n",
      "RR slope 632\n",
      "Test AUC: 0.656 (0.533, 0.783)\n",
      "Test AUC: 0.657 ± 0.064\n",
      "RR sample_entropy 612\n",
      "Test AUC: 0.634 (0.508, 0.758)\n",
      "Test AUC: 0.633 ± 0.065\n",
      "RR abs 632\n",
      "Test AUC: 0.664 (0.542, 0.788)\n",
      "Test AUC: 0.663 ± 0.063\n",
      "RR angle 632\n",
      "Test AUC: 0.648 (0.524, 0.771)\n",
      "Test AUC: 0.649 ± 0.063\n",
      "SysBP __mean_ 612\n",
      "Test AUC: 0.671 (0.555, 0.787)\n",
      "Test AUC: 0.672 ± 0.062\n",
      "SysBP slope 612\n",
      "Test AUC: 0.645 (0.522, 0.766)\n",
      "Test AUC: 0.644 ± 0.063\n",
      "SysBP sample_entropy 632\n",
      "Test AUC: 0.629 (0.503, 0.751)\n",
      "Test AUC: 0.630 ± 0.064\n",
      "SysBP abs 632\n",
      "Test AUC: 0.623 (0.497, 0.754)\n",
      "Test AUC: 0.623 ± 0.066\n",
      "SysBP angle 612\n",
      "Test AUC: 0.645 (0.522, 0.766)\n",
      "Test AUC: 0.644 ± 0.063\n",
      "DiaBP __mean_ 612\n",
      "Test AUC: 0.671 (0.555, 0.787)\n",
      "Test AUC: 0.672 ± 0.062\n",
      "DiaBP slope 612\n",
      "Test AUC: 0.648 (0.522, 0.776)\n",
      "Test AUC: 0.647 ± 0.065\n",
      "DiaBP sample_entropy 632\n",
      "Test AUC: 0.662 (0.536, 0.781)\n",
      "Test AUC: 0.661 ± 0.063\n",
      "DiaBP abs 632\n",
      "Test AUC: 0.655 (0.534, 0.780)\n",
      "Test AUC: 0.656 ± 0.064\n",
      "DiaBP angle 612\n",
      "Test AUC: 0.648 (0.522, 0.776)\n",
      "Test AUC: 0.647 ± 0.065\n",
      "SpO2 __mean_ 572\n",
      "Test AUC: 0.669 (0.545, 0.779)\n",
      "Test AUC: 0.667 ± 0.062\n",
      "SpO2 slope 572\n",
      "Test AUC: 0.669 (0.545, 0.779)\n",
      "Test AUC: 0.667 ± 0.062\n",
      "SpO2 sample_entropy 572\n",
      "Test AUC: 0.669 (0.545, 0.779)\n",
      "Test AUC: 0.667 ± 0.062\n",
      "SpO2 abs 572\n",
      "Test AUC: 0.669 (0.545, 0.779)\n",
      "Test AUC: 0.667 ± 0.062\n",
      "SpO2 angle 632\n",
      "Test AUC: 0.643 (0.518, 0.764)\n",
      "Test AUC: 0.642 ± 0.064\n"
     ]
    }
   ],
   "source": [
    "def boostrap_func_auc(i, y_true, y_score):\n",
    "    yte_true_b, yte_pred_b = utils.resample(y_true, y_score, replace=True, random_state=i)\n",
    "    return metrics.roc_curve(yte_true_b, yte_pred_b), metrics.roc_auc_score(yte_true_b, yte_pred_b)\n",
    "\n",
    "results_2 = {}\n",
    "boot_auc_scores_2 = {}\n",
    "for gi, (group, (variable, stat)) in enumerate(zip(feature_groups, feature_groups_desc)):\n",
    "    grouped = False\n",
    "    for gg in grouped_groups_:\n",
    "        if gi in gg:\n",
    "            grouped = True\n",
    "            to_drop = [i for i, name in enumerate(feature_names) if name in feature_names[\n",
    "                sum([feature_groups[i] for i in gg], [])]]\n",
    "            break\n",
    "    \n",
    "    if not grouped:\n",
    "        to_drop = [i for i, name in enumerate(feature_names) if name in feature_names[group]]\n",
    "    \n",
    "    to_keep = [i for i in range(652) if i not in to_drop]\n",
    "    Xtr, Xte = Xtr_all[:, to_keep], Xte_all[:, to_keep]\n",
    "    print(variable, stat, len(to_keep))\n",
    "    \n",
    "    clf = train_model(Xtr, ytr)\n",
    "\n",
    "    y_true = yte\n",
    "    y_score = clf.decision_function(Xte)\n",
    "    roc_curves, auc_scores = zip(*Parallel(n_jobs=4)(delayed(boostrap_func_auc)(i, y_true, y_score) for i in range(1000)))\n",
    "    print('Test AUC: {:.3f} ({:.3f}, {:.3f})'.format(np.median(auc_scores), np.percentile(auc_scores, 2.5), np.percentile(auc_scores, 97.5)))\n",
    "    print('Test AUC: {:.3f} ± {:.3f}'.format(np.mean(auc_scores), np.std(auc_scores)))\n",
    "\n",
    "    results_2[variable, stat] = (np.mean(auc_scores), np.std(auc_scores))\n",
    "    boot_auc_scores_2[variable, stat] = auc_scores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_results_2 = pd.DataFrame(results_2).T\n",
    "df_results_2.columns = ['AUC_mean', 'AUC_std']\n",
    "df_results_2.index = [n_a + ' ' + n_b for n_a, n_b in df_results_2.index]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_results_2['AUC_mean_drop'] = -(df_results_2['AUC_mean'] - 0.659)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "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>AUC_mean</th>\n",
       "      <th>AUC_std</th>\n",
       "      <th>AUC_mean_drop</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>DiaBP __mean_</td>\n",
       "      <td>0.671861</td>\n",
       "      <td>0.061826</td>\n",
       "      <td>-0.012861</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>SysBP __mean_</td>\n",
       "      <td>0.671861</td>\n",
       "      <td>0.061826</td>\n",
       "      <td>-0.012861</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>SpO2 sample_entropy</td>\n",
       "      <td>0.666833</td>\n",
       "      <td>0.061733</td>\n",
       "      <td>-0.007833</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>SpO2 abs</td>\n",
       "      <td>0.666833</td>\n",
       "      <td>0.061733</td>\n",
       "      <td>-0.007833</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>SpO2 slope</td>\n",
       "      <td>0.666833</td>\n",
       "      <td>0.061733</td>\n",
       "      <td>-0.007833</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     AUC_mean   AUC_std  AUC_mean_drop\n",
       "DiaBP __mean_        0.671861  0.061826      -0.012861\n",
       "SysBP __mean_        0.671861  0.061826      -0.012861\n",
       "SpO2 sample_entropy  0.666833  0.061733      -0.007833\n",
       "SpO2 abs             0.666833  0.061733      -0.007833\n",
       "SpO2 slope           0.666833  0.061733      -0.007833"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_results_2.sort_values(by='AUC_mean_drop').head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_results_3 = pd.DataFrame(results_2).T\n",
    "df_results_3.columns = ['AUC_mean', 'AUC_std']\n",
    "df_results_3['AUC_mean_drop'] = -(df_results_3['AUC_mean'] - 0.659)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_drop_grid = pd.DataFrame()\n",
    "for i, j in df_results_3.index:\n",
    "    df_drop_grid.loc[i,j] = df_results_3.loc[(i,j), 'AUC_mean_drop']\n",
    "\n",
    "df_drop_grid = df_drop_grid.rename(\n",
    "    columns={\n",
    "        '__mean_': 'average', 'abs': 'abs($A_1$)', 'angle': 'angle($A_1$)',\n",
    "        'sample_entropy': 'entropy'\n",
    "    },\n",
    "    index={\n",
    "        'Temp': 'Temp.', 'SysBP': 'SBP', 'DiaBP': 'DBP',\n",
    "    }\n",
    ")\n",
    "df_drop_grid.index.name = 'Vital'\n",
    "df_drop_grid.columns.name = 'Trend'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "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>Trend</th>\n",
       "      <th>average</th>\n",
       "      <th>slope</th>\n",
       "      <th>entropy</th>\n",
       "      <th>abs($A_1$)</th>\n",
       "      <th>angle($A_1$)</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Vital</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>Temp.</td>\n",
       "      <td>-0.002578</td>\n",
       "      <td>0.032435</td>\n",
       "      <td>-0.003259</td>\n",
       "      <td>0.032435</td>\n",
       "      <td>0.032435</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>HR</td>\n",
       "      <td>0.007749</td>\n",
       "      <td>-0.006428</td>\n",
       "      <td>0.005009</td>\n",
       "      <td>-0.006428</td>\n",
       "      <td>0.001755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>RR</td>\n",
       "      <td>0.025586</td>\n",
       "      <td>0.002294</td>\n",
       "      <td>0.025586</td>\n",
       "      <td>-0.004335</td>\n",
       "      <td>0.010127</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>SBP</td>\n",
       "      <td>-0.012861</td>\n",
       "      <td>0.014802</td>\n",
       "      <td>0.029064</td>\n",
       "      <td>0.036455</td>\n",
       "      <td>0.014802</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>DBP</td>\n",
       "      <td>-0.012861</td>\n",
       "      <td>0.012080</td>\n",
       "      <td>-0.001982</td>\n",
       "      <td>0.002723</td>\n",
       "      <td>0.012080</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>SpO2</td>\n",
       "      <td>-0.007833</td>\n",
       "      <td>-0.007833</td>\n",
       "      <td>-0.007833</td>\n",
       "      <td>-0.007833</td>\n",
       "      <td>0.017107</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Trend   average     slope   entropy  abs($A_1$)  angle($A_1$)\n",
       "Vital                                                        \n",
       "Temp. -0.002578  0.032435 -0.003259    0.032435      0.032435\n",
       "HR     0.007749 -0.006428  0.005009   -0.006428      0.001755\n",
       "RR     0.025586  0.002294  0.025586   -0.004335      0.010127\n",
       "SBP   -0.012861  0.014802  0.029064    0.036455      0.014802\n",
       "DBP   -0.012861  0.012080 -0.001982    0.002723      0.012080\n",
       "SpO2  -0.007833 -0.007833 -0.007833   -0.007833      0.017107"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_drop_grid"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"284.72252pt\" version=\"1.1\" viewBox=\"0 0 421.470706 284.72252\" width=\"421.470706pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 284.72252 \n",
       "L 421.470706 284.72252 \n",
       "L 421.470706 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 73.51375 248.730645 \n",
       "L 346.779297 248.730645 \n",
       "L 346.779297 21.009355 \n",
       "L 73.51375 21.009355 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"QuadMesh_1\">\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 73.51375 248.730645 \n",
       "L 119.058008 248.730645 \n",
       "L 119.058008 203.186387 \n",
       "L 73.51375 203.186387 \n",
       "L 73.51375 248.730645 \n",
       "\" style=\"fill:#d4eeb3;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 119.058008 248.730645 \n",
       "L 164.602266 248.730645 \n",
       "L 164.602266 203.186387 \n",
       "L 119.058008 203.186387 \n",
       "L 119.058008 248.730645 \n",
       "\" style=\"fill:#6bc6be;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 164.602266 248.730645 \n",
       "L 210.146523 248.730645 \n",
       "L 210.146523 203.186387 \n",
       "L 164.602266 203.186387 \n",
       "L 164.602266 248.730645 \n",
       "\" style=\"fill:#2354a3;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 210.146523 248.730645 \n",
       "L 255.690781 248.730645 \n",
       "L 255.690781 203.186387 \n",
       "L 210.146523 203.186387 \n",
       "L 210.146523 248.730645 \n",
       "\" style=\"fill:#ffffd9;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 255.690781 248.730645 \n",
       "L 301.235039 248.730645 \n",
       "L 301.235039 203.186387 \n",
       "L 255.690781 203.186387 \n",
       "L 255.690781 248.730645 \n",
       "\" style=\"fill:#ffffd9;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 301.235039 248.730645 \n",
       "L 346.779297 248.730645 \n",
       "L 346.779297 203.186387 \n",
       "L 301.235039 203.186387 \n",
       "L 301.235039 248.730645 \n",
       "\" style=\"fill:#f0f9b8;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 73.51375 203.186387 \n",
       "L 119.058008 203.186387 \n",
       "L 119.058008 157.642129 \n",
       "L 73.51375 157.642129 \n",
       "L 73.51375 203.186387 \n",
       "\" style=\"fill:#1a2b7e;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 119.058008 203.186387 \n",
       "L 164.602266 203.186387 \n",
       "L 164.602266 157.642129 \n",
       "L 119.058008 157.642129 \n",
       "L 119.058008 203.186387 \n",
       "\" style=\"fill:#ecf7b1;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 164.602266 203.186387 \n",
       "L 210.146523 203.186387 \n",
       "L 210.146523 157.642129 \n",
       "L 164.602266 157.642129 \n",
       "L 164.602266 203.186387 \n",
       "\" style=\"fill:#a7dcb7;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 210.146523 203.186387 \n",
       "L 255.690781 203.186387 \n",
       "L 255.690781 157.642129 \n",
       "L 210.146523 157.642129 \n",
       "L 210.146523 203.186387 \n",
       "\" style=\"fill:#2fa4c2;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 255.690781 203.186387 \n",
       "L 301.235039 203.186387 \n",
       "L 301.235039 157.642129 \n",
       "L 255.690781 157.642129 \n",
       "L 255.690781 203.186387 \n",
       "\" style=\"fill:#3fb4c4;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 301.235039 203.186387 \n",
       "L 346.779297 203.186387 \n",
       "L 346.779297 157.642129 \n",
       "L 301.235039 157.642129 \n",
       "L 301.235039 203.186387 \n",
       "\" style=\"fill:#f0f9b8;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 73.51375 157.642129 \n",
       "L 119.058008 157.642129 \n",
       "L 119.058008 112.097871 \n",
       "L 73.51375 112.097871 \n",
       "L 73.51375 157.642129 \n",
       "\" style=\"fill:#d9f0b3;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 119.058008 157.642129 \n",
       "L 164.602266 157.642129 \n",
       "L 164.602266 112.097871 \n",
       "L 119.058008 112.097871 \n",
       "L 119.058008 157.642129 \n",
       "\" style=\"fill:#87d0ba;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 164.602266 157.642129 \n",
       "L 210.146523 157.642129 \n",
       "L 210.146523 112.097871 \n",
       "L 164.602266 112.097871 \n",
       "L 164.602266 157.642129 \n",
       "\" style=\"fill:#2354a3;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 210.146523 157.642129 \n",
       "L 255.690781 157.642129 \n",
       "L 255.690781 112.097871 \n",
       "L 210.146523 112.097871 \n",
       "L 210.146523 157.642129 \n",
       "\" style=\"fill:#243c98;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 255.690781 157.642129 \n",
       "L 301.235039 157.642129 \n",
       "L 301.235039 112.097871 \n",
       "L 255.690781 112.097871 \n",
       "L 255.690781 157.642129 \n",
       "\" style=\"fill:#d0edb3;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 301.235039 157.642129 \n",
       "L 346.779297 157.642129 \n",
       "L 346.779297 112.097871 \n",
       "L 301.235039 112.097871 \n",
       "L 301.235039 157.642129 \n",
       "\" style=\"fill:#f0f9b8;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 73.51375 112.097871 \n",
       "L 119.058008 112.097871 \n",
       "L 119.058008 66.553613 \n",
       "L 73.51375 66.553613 \n",
       "L 73.51375 112.097871 \n",
       "\" style=\"fill:#1a2b7e;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 119.058008 112.097871 \n",
       "L 164.602266 112.097871 \n",
       "L 164.602266 66.553613 \n",
       "L 119.058008 66.553613 \n",
       "L 119.058008 112.097871 \n",
       "\" style=\"fill:#ecf7b1;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 164.602266 112.097871 \n",
       "L 210.146523 112.097871 \n",
       "L 210.146523 66.553613 \n",
       "L 164.602266 66.553613 \n",
       "L 164.602266 112.097871 \n",
       "\" style=\"fill:#dff2b2;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 210.146523 112.097871 \n",
       "L 255.690781 112.097871 \n",
       "L 255.690781 66.553613 \n",
       "L 210.146523 66.553613 \n",
       "L 210.146523 112.097871 \n",
       "\" style=\"fill:#081d58;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 255.690781 112.097871 \n",
       "L 301.235039 112.097871 \n",
       "L 301.235039 66.553613 \n",
       "L 255.690781 66.553613 \n",
       "L 255.690781 112.097871 \n",
       "\" style=\"fill:#a2dbb8;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 301.235039 112.097871 \n",
       "L 346.779297 112.097871 \n",
       "L 346.779297 66.553613 \n",
       "L 301.235039 66.553613 \n",
       "L 301.235039 112.097871 \n",
       "\" style=\"fill:#f0f9b8;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 73.51375 66.553613 \n",
       "L 119.058008 66.553613 \n",
       "L 119.058008 21.009355 \n",
       "L 73.51375 21.009355 \n",
       "L 73.51375 66.553613 \n",
       "\" style=\"fill:#1a2b7e;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 119.058008 66.553613 \n",
       "L 164.602266 66.553613 \n",
       "L 164.602266 21.009355 \n",
       "L 119.058008 21.009355 \n",
       "L 119.058008 66.553613 \n",
       "\" style=\"fill:#aedfb6;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 164.602266 66.553613 \n",
       "L 210.146523 66.553613 \n",
       "L 210.146523 21.009355 \n",
       "L 164.602266 21.009355 \n",
       "L 164.602266 66.553613 \n",
       "\" style=\"fill:#52bcc2;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 210.146523 66.553613 \n",
       "L 255.690781 66.553613 \n",
       "L 255.690781 21.009355 \n",
       "L 210.146523 21.009355 \n",
       "L 210.146523 66.553613 \n",
       "\" style=\"fill:#2fa4c2;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 255.690781 66.553613 \n",
       "L 301.235039 66.553613 \n",
       "L 301.235039 21.009355 \n",
       "L 255.690781 21.009355 \n",
       "L 255.690781 66.553613 \n",
       "\" style=\"fill:#3fb4c4;\"/>\n",
       "    <path clip-path=\"url(#p3bb6f708fb)\" d=\"M 301.235039 66.553613 \n",
       "L 346.779297 66.553613 \n",
       "L 346.779297 21.009355 \n",
       "L 301.235039 21.009355 \n",
       "L 301.235039 66.553613 \n",
       "\" style=\"fill:#2296c1;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\"/>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- Temp. -->\n",
       "      <defs>\n",
       "       <path d=\"M -0.296875 72.90625 \n",
       "L 61.375 72.90625 \n",
       "L 61.375 64.59375 \n",
       "L 35.5 64.59375 \n",
       "L 35.5 0 \n",
       "L 25.59375 0 \n",
       "L 25.59375 64.59375 \n",
       "L -0.296875 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-84\"/>\n",
       "       <path d=\"M 56.203125 29.59375 \n",
       "L 56.203125 25.203125 \n",
       "L 14.890625 25.203125 \n",
       "Q 15.484375 15.921875 20.484375 11.0625 \n",
       "Q 25.484375 6.203125 34.421875 6.203125 \n",
       "Q 39.59375 6.203125 44.453125 7.46875 \n",
       "Q 49.3125 8.734375 54.109375 11.28125 \n",
       "L 54.109375 2.78125 \n",
       "Q 49.265625 0.734375 44.1875 -0.34375 \n",
       "Q 39.109375 -1.421875 33.890625 -1.421875 \n",
       "Q 20.796875 -1.421875 13.15625 6.1875 \n",
       "Q 5.515625 13.8125 5.515625 26.8125 \n",
       "Q 5.515625 40.234375 12.765625 48.109375 \n",
       "Q 20.015625 56 32.328125 56 \n",
       "Q 43.359375 56 49.78125 48.890625 \n",
       "Q 56.203125 41.796875 56.203125 29.59375 \n",
       "z\n",
       "M 47.21875 32.234375 \n",
       "Q 47.125 39.59375 43.09375 43.984375 \n",
       "Q 39.0625 48.390625 32.421875 48.390625 \n",
       "Q 24.90625 48.390625 20.390625 44.140625 \n",
       "Q 15.875 39.890625 15.1875 32.171875 \n",
       "z\n",
       "\" id=\"DejaVuSans-101\"/>\n",
       "       <path d=\"M 52 44.1875 \n",
       "Q 55.375 50.25 60.0625 53.125 \n",
       "Q 64.75 56 71.09375 56 \n",
       "Q 79.640625 56 84.28125 50.015625 \n",
       "Q 88.921875 44.046875 88.921875 33.015625 \n",
       "L 88.921875 0 \n",
       "L 79.890625 0 \n",
       "L 79.890625 32.71875 \n",
       "Q 79.890625 40.578125 77.09375 44.375 \n",
       "Q 74.3125 48.1875 68.609375 48.1875 \n",
       "Q 61.625 48.1875 57.5625 43.546875 \n",
       "Q 53.515625 38.921875 53.515625 30.90625 \n",
       "L 53.515625 0 \n",
       "L 44.484375 0 \n",
       "L 44.484375 32.71875 \n",
       "Q 44.484375 40.625 41.703125 44.40625 \n",
       "Q 38.921875 48.1875 33.109375 48.1875 \n",
       "Q 26.21875 48.1875 22.15625 43.53125 \n",
       "Q 18.109375 38.875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.1875 51.21875 25.484375 53.609375 \n",
       "Q 29.78125 56 35.6875 56 \n",
       "Q 41.65625 56 45.828125 52.96875 \n",
       "Q 50 49.953125 52 44.1875 \n",
       "z\n",
       "\" id=\"DejaVuSans-109\"/>\n",
       "       <path d=\"M 18.109375 8.203125 \n",
       "L 18.109375 -20.796875 \n",
       "L 9.078125 -20.796875 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.390625 \n",
       "Q 20.953125 51.265625 25.265625 53.625 \n",
       "Q 29.59375 56 35.59375 56 \n",
       "Q 45.5625 56 51.78125 48.09375 \n",
       "Q 58.015625 40.1875 58.015625 27.296875 \n",
       "Q 58.015625 14.40625 51.78125 6.484375 \n",
       "Q 45.5625 -1.421875 35.59375 -1.421875 \n",
       "Q 29.59375 -1.421875 25.265625 0.953125 \n",
       "Q 20.953125 3.328125 18.109375 8.203125 \n",
       "z\n",
       "M 48.6875 27.296875 \n",
       "Q 48.6875 37.203125 44.609375 42.84375 \n",
       "Q 40.53125 48.484375 33.40625 48.484375 \n",
       "Q 26.265625 48.484375 22.1875 42.84375 \n",
       "Q 18.109375 37.203125 18.109375 27.296875 \n",
       "Q 18.109375 17.390625 22.1875 11.75 \n",
       "Q 26.265625 6.109375 33.40625 6.109375 \n",
       "Q 40.53125 6.109375 44.609375 11.75 \n",
       "Q 48.6875 17.390625 48.6875 27.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-112\"/>\n",
       "       <path d=\"M 10.6875 12.40625 \n",
       "L 21 12.40625 \n",
       "L 21 0 \n",
       "L 10.6875 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-46\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(80.535098 259.829082)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-84\"/>\n",
       "       <use x=\"60.818359\" xlink:href=\"#DejaVuSans-101\"/>\n",
       "       <use x=\"122.341797\" xlink:href=\"#DejaVuSans-109\"/>\n",
       "       <use x=\"219.753906\" xlink:href=\"#DejaVuSans-112\"/>\n",
       "       <use x=\"283.230469\" xlink:href=\"#DejaVuSans-46\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\"/>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- HR -->\n",
       "      <defs>\n",
       "       <path d=\"M 9.8125 72.90625 \n",
       "L 19.671875 72.90625 \n",
       "L 19.671875 43.015625 \n",
       "L 55.515625 43.015625 \n",
       "L 55.515625 72.90625 \n",
       "L 65.375 72.90625 \n",
       "L 65.375 0 \n",
       "L 55.515625 0 \n",
       "L 55.515625 34.71875 \n",
       "L 19.671875 34.71875 \n",
       "L 19.671875 0 \n",
       "L 9.8125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-72\"/>\n",
       "       <path d=\"M 44.390625 34.1875 \n",
       "Q 47.5625 33.109375 50.5625 29.59375 \n",
       "Q 53.5625 26.078125 56.59375 19.921875 \n",
       "L 66.609375 0 \n",
       "L 56 0 \n",
       "L 46.6875 18.703125 \n",
       "Q 43.0625 26.03125 39.671875 28.421875 \n",
       "Q 36.28125 30.8125 30.421875 30.8125 \n",
       "L 19.671875 30.8125 \n",
       "L 19.671875 0 \n",
       "L 9.8125 0 \n",
       "L 9.8125 72.90625 \n",
       "L 32.078125 72.90625 \n",
       "Q 44.578125 72.90625 50.734375 67.671875 \n",
       "Q 56.890625 62.453125 56.890625 51.90625 \n",
       "Q 56.890625 45.015625 53.6875 40.46875 \n",
       "Q 50.484375 35.9375 44.390625 34.1875 \n",
       "z\n",
       "M 19.671875 64.796875 \n",
       "L 19.671875 38.921875 \n",
       "L 32.078125 38.921875 \n",
       "Q 39.203125 38.921875 42.84375 42.21875 \n",
       "Q 46.484375 45.515625 46.484375 51.90625 \n",
       "Q 46.484375 58.296875 42.84375 61.546875 \n",
       "Q 39.203125 64.796875 32.078125 64.796875 \n",
       "z\n",
       "\" id=\"DejaVuSans-82\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(134.595762 259.829082)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-72\"/>\n",
       "       <use x=\"75.195312\" xlink:href=\"#DejaVuSans-82\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\"/>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- RR -->\n",
       "      <g transform=\"translate(180.425957 259.829082)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-82\"/>\n",
       "       <use x=\"69.482422\" xlink:href=\"#DejaVuSans-82\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\"/>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- SBP -->\n",
       "      <defs>\n",
       "       <path d=\"M 53.515625 70.515625 \n",
       "L 53.515625 60.890625 \n",
       "Q 47.90625 63.578125 42.921875 64.890625 \n",
       "Q 37.9375 66.21875 33.296875 66.21875 \n",
       "Q 25.25 66.21875 20.875 63.09375 \n",
       "Q 16.5 59.96875 16.5 54.203125 \n",
       "Q 16.5 49.359375 19.40625 46.890625 \n",
       "Q 22.3125 44.4375 30.421875 42.921875 \n",
       "L 36.375 41.703125 \n",
       "Q 47.40625 39.59375 52.65625 34.296875 \n",
       "Q 57.90625 29 57.90625 20.125 \n",
       "Q 57.90625 9.515625 50.796875 4.046875 \n",
       "Q 43.703125 -1.421875 29.984375 -1.421875 \n",
       "Q 24.8125 -1.421875 18.96875 -0.25 \n",
       "Q 13.140625 0.921875 6.890625 3.21875 \n",
       "L 6.890625 13.375 \n",
       "Q 12.890625 10.015625 18.65625 8.296875 \n",
       "Q 24.421875 6.59375 29.984375 6.59375 \n",
       "Q 38.421875 6.59375 43.015625 9.90625 \n",
       "Q 47.609375 13.234375 47.609375 19.390625 \n",
       "Q 47.609375 24.75 44.3125 27.78125 \n",
       "Q 41.015625 30.8125 33.5 32.328125 \n",
       "L 27.484375 33.5 \n",
       "Q 16.453125 35.6875 11.515625 40.375 \n",
       "Q 6.59375 45.0625 6.59375 53.421875 \n",
       "Q 6.59375 63.09375 13.40625 68.65625 \n",
       "Q 20.21875 74.21875 32.171875 74.21875 \n",
       "Q 37.3125 74.21875 42.625 73.28125 \n",
       "Q 47.953125 72.359375 53.515625 70.515625 \n",
       "z\n",
       "\" id=\"DejaVuSans-83\"/>\n",
       "       <path d=\"M 19.671875 34.8125 \n",
       "L 19.671875 8.109375 \n",
       "L 35.5 8.109375 \n",
       "Q 43.453125 8.109375 47.28125 11.40625 \n",
       "Q 51.125 14.703125 51.125 21.484375 \n",
       "Q 51.125 28.328125 47.28125 31.5625 \n",
       "Q 43.453125 34.8125 35.5 34.8125 \n",
       "z\n",
       "M 19.671875 64.796875 \n",
       "L 19.671875 42.828125 \n",
       "L 34.28125 42.828125 \n",
       "Q 41.5 42.828125 45.03125 45.53125 \n",
       "Q 48.578125 48.25 48.578125 53.8125 \n",
       "Q 48.578125 59.328125 45.03125 62.0625 \n",
       "Q 41.5 64.796875 34.28125 64.796875 \n",
       "z\n",
       "M 9.8125 72.90625 \n",
       "L 35.015625 72.90625 \n",
       "Q 46.296875 72.90625 52.390625 68.21875 \n",
       "Q 58.5 63.53125 58.5 54.890625 \n",
       "Q 58.5 48.1875 55.375 44.234375 \n",
       "Q 52.25 40.28125 46.1875 39.3125 \n",
       "Q 53.46875 37.75 57.5 32.78125 \n",
       "Q 61.53125 27.828125 61.53125 20.40625 \n",
       "Q 61.53125 10.640625 54.890625 5.3125 \n",
       "Q 48.25 0 35.984375 0 \n",
       "L 9.8125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-66\"/>\n",
       "       <path d=\"M 19.671875 64.796875 \n",
       "L 19.671875 37.40625 \n",
       "L 32.078125 37.40625 \n",
       "Q 38.96875 37.40625 42.71875 40.96875 \n",
       "Q 46.484375 44.53125 46.484375 51.125 \n",
       "Q 46.484375 57.671875 42.71875 61.234375 \n",
       "Q 38.96875 64.796875 32.078125 64.796875 \n",
       "z\n",
       "M 9.8125 72.90625 \n",
       "L 32.078125 72.90625 \n",
       "Q 44.34375 72.90625 50.609375 67.359375 \n",
       "Q 56.890625 61.8125 56.890625 51.125 \n",
       "Q 56.890625 40.328125 50.609375 34.8125 \n",
       "Q 44.34375 29.296875 32.078125 29.296875 \n",
       "L 19.671875 29.296875 \n",
       "L 19.671875 0 \n",
       "L 9.8125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-80\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(223.299121 259.829082)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-83\"/>\n",
       "       <use x=\"63.476562\" xlink:href=\"#DejaVuSans-66\"/>\n",
       "       <use x=\"132.080078\" xlink:href=\"#DejaVuSans-80\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\"/>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- DBP -->\n",
       "      <defs>\n",
       "       <path d=\"M 19.671875 64.796875 \n",
       "L 19.671875 8.109375 \n",
       "L 31.59375 8.109375 \n",
       "Q 46.6875 8.109375 53.6875 14.9375 \n",
       "Q 60.6875 21.78125 60.6875 36.53125 \n",
       "Q 60.6875 51.171875 53.6875 57.984375 \n",
       "Q 46.6875 64.796875 31.59375 64.796875 \n",
       "z\n",
       "M 9.8125 72.90625 \n",
       "L 30.078125 72.90625 \n",
       "Q 51.265625 72.90625 61.171875 64.09375 \n",
       "Q 71.09375 55.28125 71.09375 36.53125 \n",
       "Q 71.09375 17.671875 61.125 8.828125 \n",
       "Q 51.171875 0 30.078125 0 \n",
       "L 9.8125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-68\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(268.167598 259.829082)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-68\"/>\n",
       "       <use x=\"77.001953\" xlink:href=\"#DejaVuSans-66\"/>\n",
       "       <use x=\"145.605469\" xlink:href=\"#DejaVuSans-80\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_6\"/>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- SpO2 -->\n",
       "      <defs>\n",
       "       <path d=\"M 39.40625 66.21875 \n",
       "Q 28.65625 66.21875 22.328125 58.203125 \n",
       "Q 16.015625 50.203125 16.015625 36.375 \n",
       "Q 16.015625 22.609375 22.328125 14.59375 \n",
       "Q 28.65625 6.59375 39.40625 6.59375 \n",
       "Q 50.140625 6.59375 56.421875 14.59375 \n",
       "Q 62.703125 22.609375 62.703125 36.375 \n",
       "Q 62.703125 50.203125 56.421875 58.203125 \n",
       "Q 50.140625 66.21875 39.40625 66.21875 \n",
       "z\n",
       "M 39.40625 74.21875 \n",
       "Q 54.734375 74.21875 63.90625 63.9375 \n",
       "Q 73.09375 53.65625 73.09375 36.375 \n",
       "Q 73.09375 19.140625 63.90625 8.859375 \n",
       "Q 54.734375 -1.421875 39.40625 -1.421875 \n",
       "Q 24.03125 -1.421875 14.8125 8.828125 \n",
       "Q 5.609375 19.09375 5.609375 36.375 \n",
       "Q 5.609375 53.65625 14.8125 63.9375 \n",
       "Q 24.03125 74.21875 39.40625 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-79\"/>\n",
       "       <path d=\"M 19.1875 8.296875 \n",
       "L 53.609375 8.296875 \n",
       "L 53.609375 0 \n",
       "L 7.328125 0 \n",
       "L 7.328125 8.296875 \n",
       "Q 12.9375 14.109375 22.625 23.890625 \n",
       "Q 32.328125 33.6875 34.8125 36.53125 \n",
       "Q 39.546875 41.84375 41.421875 45.53125 \n",
       "Q 43.3125 49.21875 43.3125 52.78125 \n",
       "Q 43.3125 58.59375 39.234375 62.25 \n",
       "Q 35.15625 65.921875 28.609375 65.921875 \n",
       "Q 23.96875 65.921875 18.8125 64.3125 \n",
       "Q 13.671875 62.703125 7.8125 59.421875 \n",
       "L 7.8125 69.390625 \n",
       "Q 13.765625 71.78125 18.9375 73 \n",
       "Q 24.125 74.21875 28.421875 74.21875 \n",
       "Q 39.75 74.21875 46.484375 68.546875 \n",
       "Q 53.21875 62.890625 53.21875 53.421875 \n",
       "Q 53.21875 48.921875 51.53125 44.890625 \n",
       "Q 49.859375 40.875 45.40625 35.40625 \n",
       "Q 44.1875 33.984375 37.640625 27.21875 \n",
       "Q 31.109375 20.453125 19.1875 8.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-50\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(310.541543 259.829082)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-83\"/>\n",
       "       <use x=\"63.476562\" xlink:href=\"#DejaVuSans-112\"/>\n",
       "       <use x=\"126.953125\" xlink:href=\"#DejaVuSans-79\"/>\n",
       "       <use x=\"205.664062\" xlink:href=\"#DejaVuSans-50\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_7\">\n",
       "     <!-- Vital -->\n",
       "     <defs>\n",
       "      <path d=\"M 28.609375 0 \n",
       "L 0.78125 72.90625 \n",
       "L 11.078125 72.90625 \n",
       "L 34.1875 11.53125 \n",
       "L 57.328125 72.90625 \n",
       "L 67.578125 72.90625 \n",
       "L 39.796875 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-86\"/>\n",
       "      <path d=\"M 9.421875 54.6875 \n",
       "L 18.40625 54.6875 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 64.59375 \n",
       "L 9.421875 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-105\"/>\n",
       "      <path d=\"M 18.3125 70.21875 \n",
       "L 18.3125 54.6875 \n",
       "L 36.8125 54.6875 \n",
       "L 36.8125 47.703125 \n",
       "L 18.3125 47.703125 \n",
       "L 18.3125 18.015625 \n",
       "Q 18.3125 11.328125 20.140625 9.421875 \n",
       "Q 21.96875 7.515625 27.59375 7.515625 \n",
       "L 36.8125 7.515625 \n",
       "L 36.8125 0 \n",
       "L 27.59375 0 \n",
       "Q 17.1875 0 13.234375 3.875 \n",
       "Q 9.28125 7.765625 9.28125 18.015625 \n",
       "L 9.28125 47.703125 \n",
       "L 2.6875 47.703125 \n",
       "L 2.6875 54.6875 \n",
       "L 9.28125 54.6875 \n",
       "L 9.28125 70.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-116\"/>\n",
       "      <path d=\"M 34.28125 27.484375 \n",
       "Q 23.390625 27.484375 19.1875 25 \n",
       "Q 14.984375 22.515625 14.984375 16.5 \n",
       "Q 14.984375 11.71875 18.140625 8.90625 \n",
       "Q 21.296875 6.109375 26.703125 6.109375 \n",
       "Q 34.1875 6.109375 38.703125 11.40625 \n",
       "Q 43.21875 16.703125 43.21875 25.484375 \n",
       "L 43.21875 27.484375 \n",
       "z\n",
       "M 52.203125 31.203125 \n",
       "L 52.203125 0 \n",
       "L 43.21875 0 \n",
       "L 43.21875 8.296875 \n",
       "Q 40.140625 3.328125 35.546875 0.953125 \n",
       "Q 30.953125 -1.421875 24.3125 -1.421875 \n",
       "Q 15.921875 -1.421875 10.953125 3.296875 \n",
       "Q 6 8.015625 6 15.921875 \n",
       "Q 6 25.140625 12.171875 29.828125 \n",
       "Q 18.359375 34.515625 30.609375 34.515625 \n",
       "L 43.21875 34.515625 \n",
       "L 43.21875 35.40625 \n",
       "Q 43.21875 41.609375 39.140625 45 \n",
       "Q 35.0625 48.390625 27.6875 48.390625 \n",
       "Q 23 48.390625 18.546875 47.265625 \n",
       "Q 14.109375 46.140625 10.015625 43.890625 \n",
       "L 10.015625 52.203125 \n",
       "Q 14.9375 54.109375 19.578125 55.046875 \n",
       "Q 24.21875 56 28.609375 56 \n",
       "Q 40.484375 56 46.34375 49.84375 \n",
       "Q 52.203125 43.703125 52.203125 31.203125 \n",
       "z\n",
       "\" id=\"DejaVuSans-97\"/>\n",
       "      <path d=\"M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-108\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(196.681211 275.026895)scale(0.12 -0.12)\">\n",
       "      <use xlink:href=\"#DejaVuSans-86\"/>\n",
       "      <use x=\"68.376953\" xlink:href=\"#DejaVuSans-105\"/>\n",
       "      <use x=\"96.160156\" xlink:href=\"#DejaVuSans-116\"/>\n",
       "      <use x=\"135.369141\" xlink:href=\"#DejaVuSans-97\"/>\n",
       "      <use x=\"196.648438\" xlink:href=\"#DejaVuSans-108\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_7\"/>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- average -->\n",
       "      <defs>\n",
       "       <path d=\"M 2.984375 54.6875 \n",
       "L 12.5 54.6875 \n",
       "L 29.59375 8.796875 \n",
       "L 46.6875 54.6875 \n",
       "L 56.203125 54.6875 \n",
       "L 35.6875 0 \n",
       "L 23.484375 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-118\"/>\n",
       "       <path d=\"M 41.109375 46.296875 \n",
       "Q 39.59375 47.171875 37.8125 47.578125 \n",
       "Q 36.03125 48 33.890625 48 \n",
       "Q 26.265625 48 22.1875 43.046875 \n",
       "Q 18.109375 38.09375 18.109375 28.8125 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 20.953125 51.171875 25.484375 53.578125 \n",
       "Q 30.03125 56 36.53125 56 \n",
       "Q 37.453125 56 38.578125 55.875 \n",
       "Q 39.703125 55.765625 41.0625 55.515625 \n",
       "z\n",
       "\" id=\"DejaVuSans-114\"/>\n",
       "       <path d=\"M 45.40625 27.984375 \n",
       "Q 45.40625 37.75 41.375 43.109375 \n",
       "Q 37.359375 48.484375 30.078125 48.484375 \n",
       "Q 22.859375 48.484375 18.828125 43.109375 \n",
       "Q 14.796875 37.75 14.796875 27.984375 \n",
       "Q 14.796875 18.265625 18.828125 12.890625 \n",
       "Q 22.859375 7.515625 30.078125 7.515625 \n",
       "Q 37.359375 7.515625 41.375 12.890625 \n",
       "Q 45.40625 18.265625 45.40625 27.984375 \n",
       "z\n",
       "M 54.390625 6.78125 \n",
       "Q 54.390625 -7.171875 48.1875 -13.984375 \n",
       "Q 42 -20.796875 29.203125 -20.796875 \n",
       "Q 24.46875 -20.796875 20.265625 -20.09375 \n",
       "Q 16.0625 -19.390625 12.109375 -17.921875 \n",
       "L 12.109375 -9.1875 \n",
       "Q 16.0625 -11.328125 19.921875 -12.34375 \n",
       "Q 23.78125 -13.375 27.78125 -13.375 \n",
       "Q 36.625 -13.375 41.015625 -8.765625 \n",
       "Q 45.40625 -4.15625 45.40625 5.171875 \n",
       "L 45.40625 9.625 \n",
       "Q 42.625 4.78125 38.28125 2.390625 \n",
       "Q 33.9375 0 27.875 0 \n",
       "Q 17.828125 0 11.671875 7.65625 \n",
       "Q 5.515625 15.328125 5.515625 27.984375 \n",
       "Q 5.515625 40.671875 11.671875 48.328125 \n",
       "Q 17.828125 56 27.875 56 \n",
       "Q 33.9375 56 38.28125 53.609375 \n",
       "Q 42.625 51.21875 45.40625 46.390625 \n",
       "L 45.40625 54.6875 \n",
       "L 54.390625 54.6875 \n",
       "z\n",
       "\" id=\"DejaVuSans-103\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(29.073125 229.757734)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-97\"/>\n",
       "       <use x=\"61.279297\" xlink:href=\"#DejaVuSans-118\"/>\n",
       "       <use x=\"120.458984\" xlink:href=\"#DejaVuSans-101\"/>\n",
       "       <use x=\"181.982422\" xlink:href=\"#DejaVuSans-114\"/>\n",
       "       <use x=\"223.095703\" xlink:href=\"#DejaVuSans-97\"/>\n",
       "       <use x=\"284.375\" xlink:href=\"#DejaVuSans-103\"/>\n",
       "       <use x=\"347.851562\" xlink:href=\"#DejaVuSans-101\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_8\"/>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- slope -->\n",
       "      <defs>\n",
       "       <path d=\"M 44.28125 53.078125 \n",
Loading
Loading full blame...