File size: 4,044 Bytes
64c992d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | {
"cells": [
{
"cell_type": "markdown",
"id": "9f479dac",
"metadata": {},
"source": [
"# Figure 5C: implicit vs explicit correction RMSE, delta-22 vs the natural-products test set\n",
"\n",
"Bootstrap RMSE of implicit (PCM) vs explicit (OpenMM + vibrations) corrections, delta-22 vs the pooled complex/natural-product test set, chloroform and benzene (bars = mean, error bars = 2.5-97.5 percentile). Produces the ¹H panel (saved) and a ¹³C companion (inline only)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c4fd38cc",
"metadata": {},
"outputs": [],
"source": [
"import os, sys\n",
"\n",
"# make the in-repo modules importable (not pip-installed)\n",
"REPO = os.path.abspath(\"../..\")\n",
"for _p in (\"data/applications\", \"analysis/code\", \"analysis/code/shared\"):\n",
" sys.path.insert(0, os.path.join(REPO, _p))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aef1da3f",
"metadata": {},
"outputs": [],
"source": [
"from applications_reader import Applications\n",
"import applications\n",
"import applications_plots\n",
"import paths"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "178e31b6",
"metadata": {},
"outputs": [],
"source": [
"APPLICATIONS_HDF5 = paths.dataset_file(\"applications\", root=REPO)\n",
"XLSX = os.path.join(REPO, \"data\", \"applications\", \"applications_experimental.xlsx\")\n",
"\n",
"def figure_path(name):\n",
" os.makedirs(\"figures\", exist_ok=True)\n",
" return os.path.join(\"figures\", name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a013c941",
"metadata": {},
"outputs": [],
"source": [
"loader = Applications(APPLICATIONS_HDF5, XLSX)\n",
"query_df_nn = applications.build_query_df_nn(loader)\n",
"seed = applications.build_bootstrap_seed_coeffs(loader)\n",
"\n",
"# pooled \"Test Set\" bootstrap RMSE distributions (one bin over all 13 complex molecules)\n",
"grouped = {}\n",
"for nuc in [\"H\", \"C\"]:\n",
" preds = applications.apply_bootstrap_params_to_full_dataset(query_df_nn, seed[nuc], nucleus=nuc)\n",
" grouped[nuc] = applications.compute_grouped_rmse(preds, applications.ALL_IN_ONE_BIN)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3d3cf53a",
"metadata": {},
"outputs": [],
"source": [
"applications_plots.plot_nps_benefit_barplot(\n",
" loader.rmse_distribution(\"H\"), grouped[\"H\"], nucleus=\"H\",\n",
" solvents=[[\"chloroform\"], [\"benzene\"]], np_solute_groups=applications.ALL_IN_ONE_BIN,\n",
" formulas=[\"stationary_plus_pcm\", \"stationary_plus_qcd + openMM\"],\n",
" labels=[\"Implicit Solvent (SotA)\", \"Explicit Solvent + Vibrations (OpenMM)\"],\n",
" colors=[\"#A72608\", \"#61a89a\"], formula_remap=applications.FORMULA_REMAP,\n",
" figsize=(6, 5), y_min=0.0, y_max=0.37, save_path=figure_path(\"fig5c_benefit_1H.png\"))\n",
"\n",
"applications_plots.plot_nps_benefit_barplot(\n",
" loader.rmse_distribution(\"C\"), grouped[\"C\"], nucleus=\"C\",\n",
" solvents=[[\"chloroform\"], [\"benzene\"]], np_solute_groups=applications.ALL_IN_ONE_BIN,\n",
" formulas=[\"stationary_plus_pcm\", \"stationary_plus_op_vib + openMM\"],\n",
" labels=[\"Implicit Solvent (SotA)\", \"Explicit Solvent + Vibrations (OpenMM)\"],\n",
" colors=[\"#A72608\", \"#61a89a\"], formula_remap=applications.FORMULA_REMAP,\n",
" figsize=(6, 5), y_min=0.0, save_path=None) # inline-only companion, not saved to disk"
]
}
],
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
} |