Update RMMol release bundle v1.1
Browse files- MODEL_CARD.md +3 -3
- README.md +4 -4
- dataset/README.md +1 -1
- examples/RMMol_sample.ipynb +606 -0
MODEL_CARD.md
CHANGED
|
@@ -7,12 +7,12 @@ tags:
|
|
| 7 |
- molecular-representation
|
| 8 |
- rmmol
|
| 9 |
- frozen-embeddings
|
| 10 |
-
- molecule-
|
| 11 |
---
|
| 12 |
|
| 13 |
# RMMol
|
| 14 |
|
| 15 |
-
RMMol is a frozen molecular representation model based on a geometry-aware decoupled message passing encoder. This release bundle provides standardized
|
| 16 |
|
| 17 |
## Weights
|
| 18 |
|
|
@@ -35,6 +35,6 @@ The current inference and downstream-probe reproduction was run on the Spark wor
|
|
| 35 |
|
| 36 |
## Reproduction
|
| 37 |
|
| 38 |
-
Use `examples/
|
| 39 |
|
| 40 |
Generated on 2026-09-14.
|
|
|
|
| 7 |
- molecular-representation
|
| 8 |
- rmmol
|
| 9 |
- frozen-embeddings
|
| 10 |
+
- molecule-representation
|
| 11 |
---
|
| 12 |
|
| 13 |
# RMMol
|
| 14 |
|
| 15 |
+
RMMol is a frozen molecular representation model based on a geometry-aware decoupled message passing encoder. This release bundle provides standardized CSVs and a RMMol-only Jupyter sample for four domains: Biophysics, Physiological, Physical Chemistry, and Quantum Mechanics.
|
| 16 |
|
| 17 |
## Weights
|
| 18 |
|
|
|
|
| 35 |
|
| 36 |
## Reproduction
|
| 37 |
|
| 38 |
+
Use `examples/RMMol_sample.ipynb` to inspect the exact RMMol-only dataset names and selected probe settings.
|
| 39 |
|
| 40 |
Generated on 2026-09-14.
|
README.md
CHANGED
|
@@ -10,12 +10,12 @@ tags:
|
|
| 10 |
- qm9
|
| 11 |
- tox21
|
| 12 |
- sider
|
| 13 |
-
pretty_name: RMMol
|
| 14 |
---
|
| 15 |
|
| 16 |
-
# RMMol
|
| 17 |
|
| 18 |
-
This bundle contains standardized CSV files and a Jupyter sample notebook for
|
| 19 |
|
| 20 |
## Contents
|
| 21 |
|
|
@@ -23,7 +23,7 @@ This bundle contains standardized CSV files and a Jupyter sample notebook for th
|
|
| 23 |
- `dataset/physiological/`: BACE, ClinTox FDA-approved, Tox21 single-label splits, and SIDER single-label splits.
|
| 24 |
- `dataset/physical_chemistry/`: ESOL, FreeSolv, and Lipophilicity splits.
|
| 25 |
- `dataset/quantum_mechanics/`: QM9 splits.
|
| 26 |
-
- `examples/
|
| 27 |
- `MANIFEST.csv`: file-level provenance, row counts, columns, and checksums.
|
| 28 |
|
| 29 |
## Naming convention
|
|
|
|
| 10 |
- qm9
|
| 11 |
- tox21
|
| 12 |
- sider
|
| 13 |
+
pretty_name: RMMol
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# RMMol
|
| 17 |
|
| 18 |
+
This bundle contains standardized CSV files and a Jupyter sample notebook for RMMol frozen-embedding examples across Biophysics, Physiological, Physical Chemistry, and Quantum Mechanics.
|
| 19 |
|
| 20 |
## Contents
|
| 21 |
|
|
|
|
| 23 |
- `dataset/physiological/`: BACE, ClinTox FDA-approved, Tox21 single-label splits, and SIDER single-label splits.
|
| 24 |
- `dataset/physical_chemistry/`: ESOL, FreeSolv, and Lipophilicity splits.
|
| 25 |
- `dataset/quantum_mechanics/`: QM9 splits.
|
| 26 |
+
- `examples/RMMol_sample.ipynb`: RMMol-only sample notebook with the selected downstream-head settings.
|
| 27 |
- `MANIFEST.csv`: file-level provenance, row counts, columns, and checksums.
|
| 28 |
|
| 29 |
## Naming convention
|
dataset/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
# Dataset layout
|
| 2 |
|
| 3 |
-
This directory stores
|
| 4 |
|
| 5 |
Biophysics contains `biophysics/bbbp/bbbp.csv` and `biophysics/hiv/hiv_{train,val,test}.csv`.
|
|
|
|
| 1 |
# Dataset layout
|
| 2 |
|
| 3 |
+
This directory stores CSV data required for the RMMol sample. Each CSV keeps the original task label columns while standardizing split names to `train`, `val`, and `test`.
|
| 4 |
|
| 5 |
Biophysics contains `biophysics/bbbp/bbbp.csv` and `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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"metadata": {},
|
| 6 |
+
"source": [
|
| 7 |
+
"# RMMol frozen-embedding sample\n",
|
| 8 |
+
"\n",
|
| 9 |
+
"This notebook demonstrates how to load the packaged CSV files, generate RMMol embeddings, and apply the selected downstream heads. It is RMMol-only and does not include baseline model artifacts or local output tables."
|
| 10 |
+
]
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"cell_type": "code",
|
| 14 |
+
"execution_count": null,
|
| 15 |
+
"metadata": {},
|
| 16 |
+
"outputs": [],
|
| 17 |
+
"source": [
|
| 18 |
+
"from pathlib import Path\n",
|
| 19 |
+
"import os, sys, json\n",
|
| 20 |
+
"import numpy as np\n",
|
| 21 |
+
"import pandas as pd\n",
|
| 22 |
+
"from sklearn.ensemble import ExtraTreesClassifier\n",
|
| 23 |
+
"from sklearn.linear_model import Ridge, RidgeClassifier\n",
|
| 24 |
+
"from sklearn.metrics import mean_absolute_error, mean_squared_error, roc_auc_score\n",
|
| 25 |
+
"from sklearn.model_selection import KFold\n",
|
| 26 |
+
"from sklearn.pipeline import make_pipeline\n",
|
| 27 |
+
"from sklearn.preprocessing import Normalizer, StandardScaler\n",
|
| 28 |
+
"\n",
|
| 29 |
+
"RELEASE_DIR = Path(os.environ.get('RMMOL_RELEASE_DIR', Path.cwd()))\n",
|
| 30 |
+
"if not (RELEASE_DIR / 'dataset').exists():\n",
|
| 31 |
+
" RELEASE_DIR = Path.cwd().parent\n",
|
| 32 |
+
"RMMOL_CKPT = os.environ.get('RMMOL_CKPT', '')\n",
|
| 33 |
+
"RMMOL_TRUE_LOADER_DIR = Path(os.environ.get('RMMOL_TRUE_LOADER_DIR', '/home/sustech_spark/project/virtual cell/FUND/experiments'))\n",
|
| 34 |
+
"DEVICE = os.environ.get('RMMOL_DEVICE', 'cuda')\n",
|
| 35 |
+
"BATCH_SIZE = int(os.environ.get('RMMOL_BATCH_SIZE', '128'))\n"
|
| 36 |
+
]
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"cell_type": "code",
|
| 40 |
+
"execution_count": null,
|
| 41 |
+
"metadata": {},
|
| 42 |
+
"outputs": [],
|
| 43 |
+
"source": [
|
| 44 |
+
"TASK_SETTINGS = {\n",
|
| 45 |
+
" \"biophysics\": {\n",
|
| 46 |
+
" \"bbbp\": \"StandardScaler + RidgeClassifier(alpha=1.0, class_weight=None, solver='lsqr'); five-fold KFold(shuffle=True, random_state=42).\",\n",
|
| 47 |
+
" \"hiv\": \"Normalizer + RidgeClassifier(alpha=1.6788e-05, class_weight='balanced', solver='lsqr'); train+val fit, test report.\"\n",
|
| 48 |
+
" },\n",
|
| 49 |
+
" \"physiological\": {\n",
|
| 50 |
+
" \"bace\": \"ExtraTreesClassifier(n_estimators=500, criterion='entropy', max_features='sqrt', class_weight='balanced').\",\n",
|
| 51 |
+
" \"clintox_FDA_APPROVED\": \"l2-normalized RidgeClassifier(alpha=0.0003, class_weight=None).\",\n",
|
| 52 |
+
" \"tox21_and_sider\": \"Task-specific RidgeClassifier presets are embedded in the Jupyter sample notebook.\"\n",
|
| 53 |
+
" },\n",
|
| 54 |
+
" \"physical_chemistry\": {\n",
|
| 55 |
+
" \"esol\": \"Ridge(alpha=0.003), RMSE.\",\n",
|
| 56 |
+
" \"freesolv\": \"Ridge(alpha=0.003), RMSE.\",\n",
|
| 57 |
+
" \"lipo\": \"Ridge(alpha=0.001), RMSE.\"\n",
|
| 58 |
+
" },\n",
|
| 59 |
+
" \"quantum_mechanics\": {\n",
|
| 60 |
+
" \"qm9\": \"StandardScaler + Ridge(alpha=0.01), MAE over 12 QM9 targets.\"\n",
|
| 61 |
+
" }\n",
|
| 62 |
+
"}\n",
|
| 63 |
+
"\n",
|
| 64 |
+
"PHYSIOLOGICAL_TASK_PRESETS = [\n",
|
| 65 |
+
" {\n",
|
| 66 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 67 |
+
" \"task\": \"nr-ahr\",\n",
|
| 68 |
+
" \"preset\": \"l2_ridge_a0.0003_cwbalanced\",\n",
|
| 69 |
+
" \"preset_params\": {\n",
|
| 70 |
+
" \"alpha\": 0.0003,\n",
|
| 71 |
+
" \"class_weight\": \"balanced\",\n",
|
| 72 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 73 |
+
" }\n",
|
| 74 |
+
" },\n",
|
| 75 |
+
" {\n",
|
| 76 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 77 |
+
" \"task\": \"nr-ar-lbd\",\n",
|
| 78 |
+
" \"preset\": \"std_l2_ridge_a0.003_cwnone\",\n",
|
| 79 |
+
" \"preset_params\": {\n",
|
| 80 |
+
" \"alpha\": 0.003,\n",
|
| 81 |
+
" \"class_weight\": null,\n",
|
| 82 |
+
" \"head\": \"std_l2+RidgeClassifier\"\n",
|
| 83 |
+
" }\n",
|
| 84 |
+
" },\n",
|
| 85 |
+
" {\n",
|
| 86 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 87 |
+
" \"task\": \"nr-ar\",\n",
|
| 88 |
+
" \"preset\": \"pca64_ridge_a100_cwbalanced\",\n",
|
| 89 |
+
" \"preset_params\": {\n",
|
| 90 |
+
" \"alpha\": 100,\n",
|
| 91 |
+
" \"class_weight\": \"balanced\",\n",
|
| 92 |
+
" \"head\": \"pca+RidgeClassifier\",\n",
|
| 93 |
+
" \"n_components\": 64\n",
|
| 94 |
+
" }\n",
|
| 95 |
+
" },\n",
|
| 96 |
+
" {\n",
|
| 97 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 98 |
+
" \"task\": \"nr-aromatase\",\n",
|
| 99 |
+
" \"preset\": \"std_l2_ridge_a10_cwbalanced\",\n",
|
| 100 |
+
" \"preset_params\": {\n",
|
| 101 |
+
" \"alpha\": 10,\n",
|
| 102 |
+
" \"class_weight\": \"balanced\",\n",
|
| 103 |
+
" \"head\": \"std_l2+RidgeClassifier\"\n",
|
| 104 |
+
" }\n",
|
| 105 |
+
" },\n",
|
| 106 |
+
" {\n",
|
| 107 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 108 |
+
" \"task\": \"nr-er-lbd\",\n",
|
| 109 |
+
" \"preset\": \"l2_ridge_a0.0003_cwbalanced\",\n",
|
| 110 |
+
" \"preset_params\": {\n",
|
| 111 |
+
" \"alpha\": 0.0003,\n",
|
| 112 |
+
" \"class_weight\": \"balanced\",\n",
|
| 113 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 114 |
+
" }\n",
|
| 115 |
+
" },\n",
|
| 116 |
+
" {\n",
|
| 117 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 118 |
+
" \"task\": \"nr-er\",\n",
|
| 119 |
+
" \"preset\": \"std_l2_ridge_a0.0003_cwnone\",\n",
|
| 120 |
+
" \"preset_params\": {\n",
|
| 121 |
+
" \"alpha\": 0.0003,\n",
|
| 122 |
+
" \"class_weight\": null,\n",
|
| 123 |
+
" \"head\": \"std_l2+RidgeClassifier\"\n",
|
| 124 |
+
" }\n",
|
| 125 |
+
" },\n",
|
| 126 |
+
" {\n",
|
| 127 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 128 |
+
" \"task\": \"nr-ppar-gamma\",\n",
|
| 129 |
+
" \"preset\": \"std_l2_ridge_a0.003_cwnone\",\n",
|
| 130 |
+
" \"preset_params\": {\n",
|
| 131 |
+
" \"alpha\": 0.003,\n",
|
| 132 |
+
" \"class_weight\": null,\n",
|
| 133 |
+
" \"head\": \"std_l2+RidgeClassifier\"\n",
|
| 134 |
+
" }\n",
|
| 135 |
+
" },\n",
|
| 136 |
+
" {\n",
|
| 137 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 138 |
+
" \"task\": \"sr-are\",\n",
|
| 139 |
+
" \"preset\": \"std_l2_ridge_a0.003_cwbalanced\",\n",
|
| 140 |
+
" \"preset_params\": {\n",
|
| 141 |
+
" \"alpha\": 0.003,\n",
|
| 142 |
+
" \"class_weight\": \"balanced\",\n",
|
| 143 |
+
" \"head\": \"std_l2+RidgeClassifier\"\n",
|
| 144 |
+
" }\n",
|
| 145 |
+
" },\n",
|
| 146 |
+
" {\n",
|
| 147 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 148 |
+
" \"task\": \"sr-atad5\",\n",
|
| 149 |
+
" \"preset\": \"std_l2_ridge_a0.001_cwbalanced\",\n",
|
| 150 |
+
" \"preset_params\": {\n",
|
| 151 |
+
" \"alpha\": 0.001,\n",
|
| 152 |
+
" \"class_weight\": \"balanced\",\n",
|
| 153 |
+
" \"head\": \"std_l2+RidgeClassifier\"\n",
|
| 154 |
+
" }\n",
|
| 155 |
+
" },\n",
|
| 156 |
+
" {\n",
|
| 157 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 158 |
+
" \"task\": \"sr-hse\",\n",
|
| 159 |
+
" \"preset\": \"l2_ridge_a3e-05_cwnone\",\n",
|
| 160 |
+
" \"preset_params\": {\n",
|
| 161 |
+
" \"alpha\": 3e-05,\n",
|
| 162 |
+
" \"class_weight\": null,\n",
|
| 163 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 164 |
+
" }\n",
|
| 165 |
+
" },\n",
|
| 166 |
+
" {\n",
|
| 167 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 168 |
+
" \"task\": \"sr-mmp\",\n",
|
| 169 |
+
" \"preset\": \"std_l2_ridge_a0.001_cwnone\",\n",
|
| 170 |
+
" \"preset_params\": {\n",
|
| 171 |
+
" \"alpha\": 0.001,\n",
|
| 172 |
+
" \"class_weight\": null,\n",
|
| 173 |
+
" \"head\": \"std_l2+RidgeClassifier\"\n",
|
| 174 |
+
" }\n",
|
| 175 |
+
" },\n",
|
| 176 |
+
" {\n",
|
| 177 |
+
" \"dataset_key\": \"tox21\",\n",
|
| 178 |
+
" \"task\": \"sr-p53\",\n",
|
| 179 |
+
" \"preset\": \"std_l2_ridge_a1e-05_cwbalanced\",\n",
|
| 180 |
+
" \"preset_params\": {\n",
|
| 181 |
+
" \"alpha\": 1e-05,\n",
|
| 182 |
+
" \"class_weight\": \"balanced\",\n",
|
| 183 |
+
" \"head\": \"std_l2+RidgeClassifier\"\n",
|
| 184 |
+
" }\n",
|
| 185 |
+
" },\n",
|
| 186 |
+
" {\n",
|
| 187 |
+
" \"dataset_key\": \"sider\",\n",
|
| 188 |
+
" \"task\": \"blood and lymphatic system disorders\",\n",
|
| 189 |
+
" \"preset\": \"l2_ridge_a0.3_cwbalanced\",\n",
|
| 190 |
+
" \"preset_params\": {\n",
|
| 191 |
+
" \"alpha\": 0.3,\n",
|
| 192 |
+
" \"class_weight\": \"balanced\",\n",
|
| 193 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 194 |
+
" }\n",
|
| 195 |
+
" },\n",
|
| 196 |
+
" {\n",
|
| 197 |
+
" \"dataset_key\": \"sider\",\n",
|
| 198 |
+
" \"task\": \"cardiac disorders\",\n",
|
| 199 |
+
" \"preset\": \"l2_ridge_a0.3_cwbalanced\",\n",
|
| 200 |
+
" \"preset_params\": {\n",
|
| 201 |
+
" \"alpha\": 0.3,\n",
|
| 202 |
+
" \"class_weight\": \"balanced\",\n",
|
| 203 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 204 |
+
" }\n",
|
| 205 |
+
" },\n",
|
| 206 |
+
" {\n",
|
| 207 |
+
" \"dataset_key\": \"sider\",\n",
|
| 208 |
+
" \"task\": \"congenital, familial and genetic disorders\",\n",
|
| 209 |
+
" \"preset\": \"svd128_ridge_a0.001_cwbalanced\",\n",
|
| 210 |
+
" \"preset_params\": {\n",
|
| 211 |
+
" \"alpha\": 0.001,\n",
|
| 212 |
+
" \"class_weight\": \"balanced\",\n",
|
| 213 |
+
" \"head\": \"svd+RidgeClassifier\",\n",
|
| 214 |
+
" \"n_components\": 128\n",
|
| 215 |
+
" }\n",
|
| 216 |
+
" },\n",
|
| 217 |
+
" {\n",
|
| 218 |
+
" \"dataset_key\": \"sider\",\n",
|
| 219 |
+
" \"task\": \"ear and labyrinth disorders\",\n",
|
| 220 |
+
" \"preset\": \"l2_ridge_a0.3_cwbalanced\",\n",
|
| 221 |
+
" \"preset_params\": {\n",
|
| 222 |
+
" \"alpha\": 0.3,\n",
|
| 223 |
+
" \"class_weight\": \"balanced\",\n",
|
| 224 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 225 |
+
" }\n",
|
| 226 |
+
" },\n",
|
| 227 |
+
" {\n",
|
| 228 |
+
" \"dataset_key\": \"sider\",\n",
|
| 229 |
+
" \"task\": \"endocrine disorders\",\n",
|
| 230 |
+
" \"preset\": \"minmax_ridge_a0.0001_cwnone\",\n",
|
| 231 |
+
" \"preset_params\": {\n",
|
| 232 |
+
" \"alpha\": 0.0001,\n",
|
| 233 |
+
" \"class_weight\": null,\n",
|
| 234 |
+
" \"head\": \"minmax+RidgeClassifier\"\n",
|
| 235 |
+
" }\n",
|
| 236 |
+
" },\n",
|
| 237 |
+
" {\n",
|
| 238 |
+
" \"dataset_key\": \"sider\",\n",
|
| 239 |
+
" \"task\": \"eye disorders\",\n",
|
| 240 |
+
" \"preset\": \"l2_ridge_a0.03_cwbalanced\",\n",
|
| 241 |
+
" \"preset_params\": {\n",
|
| 242 |
+
" \"alpha\": 0.03,\n",
|
| 243 |
+
" \"class_weight\": \"balanced\",\n",
|
| 244 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 245 |
+
" }\n",
|
| 246 |
+
" },\n",
|
| 247 |
+
" {\n",
|
| 248 |
+
" \"dataset_key\": \"sider\",\n",
|
| 249 |
+
" \"task\": \"gastrointestinal disorders\",\n",
|
| 250 |
+
" \"preset\": \"l2_ridge_a3_cwnone\",\n",
|
| 251 |
+
" \"preset_params\": {\n",
|
| 252 |
+
" \"alpha\": 3,\n",
|
| 253 |
+
" \"class_weight\": null,\n",
|
| 254 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 255 |
+
" }\n",
|
| 256 |
+
" },\n",
|
| 257 |
+
" {\n",
|
| 258 |
+
" \"dataset_key\": \"sider\",\n",
|
| 259 |
+
" \"task\": \"general disorders and administration site conditions\",\n",
|
| 260 |
+
" \"preset\": \"l2_ridge_a0.03_cwnone\",\n",
|
| 261 |
+
" \"preset_params\": {\n",
|
| 262 |
+
" \"alpha\": 0.03,\n",
|
| 263 |
+
" \"class_weight\": null,\n",
|
| 264 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 265 |
+
" }\n",
|
| 266 |
+
" },\n",
|
| 267 |
+
" {\n",
|
| 268 |
+
" \"dataset_key\": \"sider\",\n",
|
| 269 |
+
" \"task\": \"hepatobiliary disorders\",\n",
|
| 270 |
+
" \"preset\": \"l2_ridge_a1_cwnone\",\n",
|
| 271 |
+
" \"preset_params\": {\n",
|
| 272 |
+
" \"alpha\": 1,\n",
|
| 273 |
+
" \"class_weight\": null,\n",
|
| 274 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 275 |
+
" }\n",
|
| 276 |
+
" },\n",
|
| 277 |
+
" {\n",
|
| 278 |
+
" \"dataset_key\": \"sider\",\n",
|
| 279 |
+
" \"task\": \"immune system disorders\",\n",
|
| 280 |
+
" \"preset\": \"l2_ridge_a1_cwbalanced\",\n",
|
| 281 |
+
" \"preset_params\": {\n",
|
| 282 |
+
" \"alpha\": 1,\n",
|
| 283 |
+
" \"class_weight\": \"balanced\",\n",
|
| 284 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 285 |
+
" }\n",
|
| 286 |
+
" },\n",
|
| 287 |
+
" {\n",
|
| 288 |
+
" \"dataset_key\": \"sider\",\n",
|
| 289 |
+
" \"task\": \"infections and infestations\",\n",
|
| 290 |
+
" \"preset\": \"l2_ridge_a3_cwnone\",\n",
|
| 291 |
+
" \"preset_params\": {\n",
|
| 292 |
+
" \"alpha\": 3,\n",
|
| 293 |
+
" \"class_weight\": null,\n",
|
| 294 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 295 |
+
" }\n",
|
| 296 |
+
" },\n",
|
| 297 |
+
" {\n",
|
| 298 |
+
" \"dataset_key\": \"sider\",\n",
|
| 299 |
+
" \"task\": \"injury, poisoning and procedural complications\",\n",
|
| 300 |
+
" \"preset\": \"l2_ridge_a3_cwnone\",\n",
|
| 301 |
+
" \"preset_params\": {\n",
|
| 302 |
+
" \"alpha\": 3,\n",
|
| 303 |
+
" \"class_weight\": null,\n",
|
| 304 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 305 |
+
" }\n",
|
| 306 |
+
" },\n",
|
| 307 |
+
" {\n",
|
| 308 |
+
" \"dataset_key\": \"sider\",\n",
|
| 309 |
+
" \"task\": \"investigations\",\n",
|
| 310 |
+
" \"preset\": \"std_l2_ridge_a0.1_cwbalanced\",\n",
|
| 311 |
+
" \"preset_params\": {\n",
|
| 312 |
+
" \"alpha\": 0.1,\n",
|
| 313 |
+
" \"class_weight\": \"balanced\",\n",
|
| 314 |
+
" \"head\": \"std_l2+RidgeClassifier\"\n",
|
| 315 |
+
" }\n",
|
| 316 |
+
" },\n",
|
| 317 |
+
" {\n",
|
| 318 |
+
" \"dataset_key\": \"sider\",\n",
|
| 319 |
+
" \"task\": \"metabolism and nutrition disorders\",\n",
|
| 320 |
+
" \"preset\": \"l2_ridge_a3_cwbalanced\",\n",
|
| 321 |
+
" \"preset_params\": {\n",
|
| 322 |
+
" \"alpha\": 3,\n",
|
| 323 |
+
" \"class_weight\": \"balanced\",\n",
|
| 324 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 325 |
+
" }\n",
|
| 326 |
+
" },\n",
|
| 327 |
+
" {\n",
|
| 328 |
+
" \"dataset_key\": \"sider\",\n",
|
| 329 |
+
" \"task\": \"musculoskeletal and connective tissue disorders\",\n",
|
| 330 |
+
" \"preset\": \"l2_ridge_a0.03_cwnone\",\n",
|
| 331 |
+
" \"preset_params\": {\n",
|
| 332 |
+
" \"alpha\": 0.03,\n",
|
| 333 |
+
" \"class_weight\": null,\n",
|
| 334 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 335 |
+
" }\n",
|
| 336 |
+
" },\n",
|
| 337 |
+
" {\n",
|
| 338 |
+
" \"dataset_key\": \"sider\",\n",
|
| 339 |
+
" \"task\": \"neoplasms benign, malignant and unspecified (incl cysts and polyps)\",\n",
|
| 340 |
+
" \"preset\": \"l2_ridge_a1e-05_cwbalanced\",\n",
|
| 341 |
+
" \"preset_params\": {\n",
|
| 342 |
+
" \"alpha\": 1e-05,\n",
|
| 343 |
+
" \"class_weight\": \"balanced\",\n",
|
| 344 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 345 |
+
" }\n",
|
| 346 |
+
" },\n",
|
| 347 |
+
" {\n",
|
| 348 |
+
" \"dataset_key\": \"sider\",\n",
|
| 349 |
+
" \"task\": \"nervous system disorders\",\n",
|
| 350 |
+
" \"preset\": \"minmax_ridge_a30_cwbalanced\",\n",
|
| 351 |
+
" \"preset_params\": {\n",
|
| 352 |
+
" \"alpha\": 30,\n",
|
| 353 |
+
" \"class_weight\": \"balanced\",\n",
|
| 354 |
+
" \"head\": \"minmax+RidgeClassifier\"\n",
|
| 355 |
+
" }\n",
|
| 356 |
+
" },\n",
|
| 357 |
+
" {\n",
|
| 358 |
+
" \"dataset_key\": \"sider\",\n",
|
| 359 |
+
" \"task\": \"pregnancy, puerperium and perinatal conditions\",\n",
|
| 360 |
+
" \"preset\": \"svd32_ridge_a0.001_cwnone\",\n",
|
| 361 |
+
" \"preset_params\": {\n",
|
| 362 |
+
" \"alpha\": 0.001,\n",
|
| 363 |
+
" \"class_weight\": null,\n",
|
| 364 |
+
" \"head\": \"svd+RidgeClassifier\",\n",
|
| 365 |
+
" \"n_components\": 32\n",
|
| 366 |
+
" }\n",
|
| 367 |
+
" },\n",
|
| 368 |
+
" {\n",
|
| 369 |
+
" \"dataset_key\": \"sider\",\n",
|
| 370 |
+
" \"task\": \"product issues\",\n",
|
| 371 |
+
" \"preset\": \"l2_ridge_a1000_cwbalanced\",\n",
|
| 372 |
+
" \"preset_params\": {\n",
|
| 373 |
+
" \"alpha\": 1000,\n",
|
| 374 |
+
" \"class_weight\": \"balanced\",\n",
|
| 375 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 376 |
+
" }\n",
|
| 377 |
+
" },\n",
|
| 378 |
+
" {\n",
|
| 379 |
+
" \"dataset_key\": \"sider\",\n",
|
| 380 |
+
" \"task\": \"psychiatric disorders\",\n",
|
| 381 |
+
" \"preset\": \"l2_ridge_a1_cwbalanced\",\n",
|
| 382 |
+
" \"preset_params\": {\n",
|
| 383 |
+
" \"alpha\": 1,\n",
|
| 384 |
+
" \"class_weight\": \"balanced\",\n",
|
| 385 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 386 |
+
" }\n",
|
| 387 |
+
" },\n",
|
| 388 |
+
" {\n",
|
| 389 |
+
" \"dataset_key\": \"sider\",\n",
|
| 390 |
+
" \"task\": \"renal and urinary disorders\",\n",
|
| 391 |
+
" \"preset\": \"l2_ridge_a0.1_cwnone\",\n",
|
| 392 |
+
" \"preset_params\": {\n",
|
| 393 |
+
" \"alpha\": 0.1,\n",
|
| 394 |
+
" \"class_weight\": null,\n",
|
| 395 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 396 |
+
" }\n",
|
| 397 |
+
" },\n",
|
| 398 |
+
" {\n",
|
| 399 |
+
" \"dataset_key\": \"sider\",\n",
|
| 400 |
+
" \"task\": \"reproductive system and breast disorders\",\n",
|
| 401 |
+
" \"preset\": \"l2_ridge_a3e-05_cwbalanced\",\n",
|
| 402 |
+
" \"preset_params\": {\n",
|
| 403 |
+
" \"alpha\": 3e-05,\n",
|
| 404 |
+
" \"class_weight\": \"balanced\",\n",
|
| 405 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 406 |
+
" }\n",
|
| 407 |
+
" },\n",
|
| 408 |
+
" {\n",
|
| 409 |
+
" \"dataset_key\": \"sider\",\n",
|
| 410 |
+
" \"task\": \"respiratory, thoracic and mediastinal disorders\",\n",
|
| 411 |
+
" \"preset\": \"l2_ridge_a1_cwnone\",\n",
|
| 412 |
+
" \"preset_params\": {\n",
|
| 413 |
+
" \"alpha\": 1,\n",
|
| 414 |
+
" \"class_weight\": null,\n",
|
| 415 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 416 |
+
" }\n",
|
| 417 |
+
" },\n",
|
| 418 |
+
" {\n",
|
| 419 |
+
" \"dataset_key\": \"sider\",\n",
|
| 420 |
+
" \"task\": \"skin and subcutaneous tissue disorders\",\n",
|
| 421 |
+
" \"preset\": \"l2_ridge_a1000_cwbalanced\",\n",
|
| 422 |
+
" \"preset_params\": {\n",
|
| 423 |
+
" \"alpha\": 1000,\n",
|
| 424 |
+
" \"class_weight\": \"balanced\",\n",
|
| 425 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 426 |
+
" }\n",
|
| 427 |
+
" },\n",
|
| 428 |
+
" {\n",
|
| 429 |
+
" \"dataset_key\": \"sider\",\n",
|
| 430 |
+
" \"task\": \"social circumstances\",\n",
|
| 431 |
+
" \"preset\": \"l2_ridge_a3_cwbalanced\",\n",
|
| 432 |
+
" \"preset_params\": {\n",
|
| 433 |
+
" \"alpha\": 3,\n",
|
| 434 |
+
" \"class_weight\": \"balanced\",\n",
|
| 435 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 436 |
+
" }\n",
|
| 437 |
+
" },\n",
|
| 438 |
+
" {\n",
|
| 439 |
+
" \"dataset_key\": \"sider\",\n",
|
| 440 |
+
" \"task\": \"surgical and medical procedures\",\n",
|
| 441 |
+
" \"preset\": \"std_l2_ridge_a1e-05_cwnone\",\n",
|
| 442 |
+
" \"preset_params\": {\n",
|
| 443 |
+
" \"alpha\": 1e-05,\n",
|
| 444 |
+
" \"class_weight\": null,\n",
|
| 445 |
+
" \"head\": \"std_l2+RidgeClassifier\"\n",
|
| 446 |
+
" }\n",
|
| 447 |
+
" },\n",
|
| 448 |
+
" {\n",
|
| 449 |
+
" \"dataset_key\": \"sider\",\n",
|
| 450 |
+
" \"task\": \"vascular disorders\",\n",
|
| 451 |
+
" \"preset\": \"l2_ridge_a0.0003_cwnone\",\n",
|
| 452 |
+
" \"preset_params\": {\n",
|
| 453 |
+
" \"alpha\": 0.0003,\n",
|
| 454 |
+
" \"class_weight\": null,\n",
|
| 455 |
+
" \"head\": \"l2+RidgeClassifier\"\n",
|
| 456 |
+
" }\n",
|
| 457 |
+
" }\n",
|
| 458 |
+
"]\n",
|
| 459 |
+
"\n",
|
| 460 |
+
"print(json.dumps(TASK_SETTINGS, indent=2))\n",
|
| 461 |
+
"print(f'Loaded {len(PHYSIOLOGICAL_TASK_PRESETS)} Tox21/SIDER task-specific settings')\n"
|
| 462 |
+
]
|
| 463 |
+
},
|
| 464 |
+
{
|
| 465 |
+
"cell_type": "code",
|
| 466 |
+
"execution_count": null,
|
| 467 |
+
"metadata": {},
|
| 468 |
+
"outputs": [],
|
| 469 |
+
"source": [
|
| 470 |
+
"def encode_rmmol_smiles(smiles):\n",
|
| 471 |
+
" if not RMMOL_CKPT:\n",
|
| 472 |
+
" raise RuntimeError('Set RMMOL_CKPT to the downloaded RMMol checkpoint path before encoding.')\n",
|
| 473 |
+
" sys.path.insert(0, str(RMMOL_TRUE_LOADER_DIR))\n",
|
| 474 |
+
" from rmmol_true_loader import encode_smiles_true_loader\n",
|
| 475 |
+
" embeddings, valid_indices, cfg = encode_smiles_true_loader(\n",
|
| 476 |
+
" list(smiles), checkpoint=Path(RMMOL_CKPT), batch_size=BATCH_SIZE, device=DEVICE\n",
|
| 477 |
+
" )\n",
|
| 478 |
+
" return embeddings, np.asarray(valid_indices, dtype=int), cfg\n",
|
| 479 |
+
"\n",
|
| 480 |
+
"def read_splits(domain, dataset, prefix):\n",
|
| 481 |
+
" frames = []\n",
|
| 482 |
+
" for split in ['train', 'val', 'test']:\n",
|
| 483 |
+
" frame = pd.read_csv(RELEASE_DIR / 'dataset' / domain / dataset / f'{prefix}_{split}.csv')\n",
|
| 484 |
+
" frame['_split'] = split\n",
|
| 485 |
+
" frames.append(frame)\n",
|
| 486 |
+
" return pd.concat(frames, ignore_index=True)\n",
|
| 487 |
+
"\n",
|
| 488 |
+
"def fit_auc(head_factory, x, y, folds):\n",
|
| 489 |
+
" scores = []\n",
|
| 490 |
+
" for train_idx, test_idx in folds:\n",
|
| 491 |
+
" model = head_factory()\n",
|
| 492 |
+
" model.fit(x[train_idx], y[train_idx])\n",
|
| 493 |
+
" pred = model.decision_function(x[test_idx])\n",
|
| 494 |
+
" scores.append(roc_auc_score(y[test_idx], pred))\n",
|
| 495 |
+
" return float(np.mean(scores)), float(np.std(scores, ddof=0))\n"
|
| 496 |
+
]
|
| 497 |
+
},
|
| 498 |
+
{
|
| 499 |
+
"cell_type": "markdown",
|
| 500 |
+
"metadata": {},
|
| 501 |
+
"source": [
|
| 502 |
+
"## Biophysics examples"
|
| 503 |
+
]
|
| 504 |
+
},
|
| 505 |
+
{
|
| 506 |
+
"cell_type": "code",
|
| 507 |
+
"execution_count": null,
|
| 508 |
+
"metadata": {},
|
| 509 |
+
"outputs": [],
|
| 510 |
+
"source": [
|
| 511 |
+
"bbbp = pd.read_csv(RELEASE_DIR / 'dataset' / 'biophysics' / 'bbbp' / 'bbbp.csv')\n",
|
| 512 |
+
"x_bbbp, valid_bbbp, _ = encode_rmmol_smiles(bbbp['smiles'])\n",
|
| 513 |
+
"y_bbbp = bbbp.iloc[valid_bbbp]['p_np'].astype(int).to_numpy()\n",
|
| 514 |
+
"folds = list(KFold(n_splits=5, shuffle=True, random_state=42).split(x_bbbp))\n",
|
| 515 |
+
"bbbp_auc, bbbp_std = fit_auc(\n",
|
| 516 |
+
" lambda: make_pipeline(StandardScaler(), RidgeClassifier(alpha=1.0, class_weight=None, solver='lsqr')),\n",
|
| 517 |
+
" x_bbbp, y_bbbp, folds\n",
|
| 518 |
+
")\n",
|
| 519 |
+
"print({'dataset': 'bbbp', 'metric': 'ROC-AUC', 'mean': bbbp_auc, 'std': bbbp_std, 'n': len(y_bbbp)})\n",
|
| 520 |
+
"\n",
|
| 521 |
+
"hiv = read_splits('biophysics', 'hiv', 'hiv')\n",
|
| 522 |
+
"x_hiv, valid_hiv, _ = encode_rmmol_smiles(hiv['smiles'])\n",
|
| 523 |
+
"hiv_valid = hiv.iloc[valid_hiv].reset_index(drop=True)\n",
|
| 524 |
+
"y_hiv = hiv_valid['HIV_active'].astype(int).to_numpy()\n",
|
| 525 |
+
"trainval = hiv_valid['_split'].isin(['train', 'val']).to_numpy()\n",
|
| 526 |
+
"test = hiv_valid['_split'].eq('test').to_numpy()\n",
|
| 527 |
+
"hiv_head = make_pipeline(Normalizer(), RidgeClassifier(alpha=1.6788e-05, class_weight='balanced', solver='lsqr'))\n",
|
| 528 |
+
"hiv_head.fit(x_hiv[trainval], y_hiv[trainval])\n",
|
| 529 |
+
"hiv_auc = roc_auc_score(y_hiv[test], hiv_head.decision_function(x_hiv[test]))\n",
|
| 530 |
+
"print({'dataset': 'hiv', 'metric': 'ROC-AUC', 'test': float(hiv_auc), 'n_test': int(test.sum())})\n"
|
| 531 |
+
]
|
| 532 |
+
},
|
| 533 |
+
{
|
| 534 |
+
"cell_type": "markdown",
|
| 535 |
+
"metadata": {},
|
| 536 |
+
"source": [
|
| 537 |
+
"## Physical chemistry example"
|
| 538 |
+
]
|
| 539 |
+
},
|
| 540 |
+
{
|
| 541 |
+
"cell_type": "code",
|
| 542 |
+
"execution_count": null,
|
| 543 |
+
"metadata": {},
|
| 544 |
+
"outputs": [],
|
| 545 |
+
"source": [
|
| 546 |
+
"def regression_cv(domain, dataset, prefix, label, alpha):\n",
|
| 547 |
+
" frame = read_splits(domain, dataset, prefix)\n",
|
| 548 |
+
" x, valid, _ = encode_rmmol_smiles(frame['smiles'])\n",
|
| 549 |
+
" y = frame.iloc[valid][label].astype(float).to_numpy()\n",
|
| 550 |
+
" folds = KFold(n_splits=5, shuffle=True, random_state=42).split(x)\n",
|
| 551 |
+
" rmses = []\n",
|
| 552 |
+
" for train_idx, test_idx in folds:\n",
|
| 553 |
+
" model = make_pipeline(StandardScaler(), Ridge(alpha=alpha))\n",
|
| 554 |
+
" model.fit(x[train_idx], y[train_idx])\n",
|
| 555 |
+
" pred = model.predict(x[test_idx])\n",
|
| 556 |
+
" rmses.append(mean_squared_error(y[test_idx], pred, squared=False))\n",
|
| 557 |
+
" return float(np.mean(rmses)), float(np.std(rmses, ddof=0)), len(y)\n",
|
| 558 |
+
"\n",
|
| 559 |
+
"esol_rmse, esol_std, esol_n = regression_cv(\n",
|
| 560 |
+
" 'physical_chemistry', 'esol', 'esol', 'ESOL predicted log solubility in mols per litre', 0.003\n",
|
| 561 |
+
")\n",
|
| 562 |
+
"print({'dataset': 'esol', 'metric': 'RMSE', 'mean': esol_rmse, 'std': esol_std, 'n': esol_n})\n"
|
| 563 |
+
]
|
| 564 |
+
},
|
| 565 |
+
{
|
| 566 |
+
"cell_type": "markdown",
|
| 567 |
+
"metadata": {},
|
| 568 |
+
"source": [
|
| 569 |
+
"## Quantum mechanics example"
|
| 570 |
+
]
|
| 571 |
+
},
|
| 572 |
+
{
|
| 573 |
+
"cell_type": "code",
|
| 574 |
+
"execution_count": null,
|
| 575 |
+
"metadata": {},
|
| 576 |
+
"outputs": [],
|
| 577 |
+
"source": [
|
| 578 |
+
"qm9_tasks = ['mu', 'alpha', 'homo', 'lumo', 'gap', 'r2', 'zpve', 'u0', 'u298', 'h298', 'g298', 'cv']\n",
|
| 579 |
+
"qm9 = read_splits('quantum_mechanics', 'qm9', 'qm9')\n",
|
| 580 |
+
"x_qm9, valid_qm9, _ = encode_rmmol_smiles(qm9['smiles'])\n",
|
| 581 |
+
"y_qm9 = qm9.iloc[valid_qm9][qm9_tasks].astype(float).to_numpy()\n",
|
| 582 |
+
"folds = KFold(n_splits=5, shuffle=True, random_state=42).split(x_qm9)\n",
|
| 583 |
+
"maes = []\n",
|
| 584 |
+
"for train_idx, test_idx in folds:\n",
|
| 585 |
+
" model = make_pipeline(StandardScaler(), Ridge(alpha=0.01))\n",
|
| 586 |
+
" model.fit(x_qm9[train_idx], y_qm9[train_idx])\n",
|
| 587 |
+
" pred = model.predict(x_qm9[test_idx])\n",
|
| 588 |
+
" maes.append(mean_absolute_error(y_qm9[test_idx], pred))\n",
|
| 589 |
+
"print({'dataset': 'qm9', 'metric': 'MAE', 'mean': float(np.mean(maes)), 'std': float(np.std(maes, ddof=0)), 'n': len(y_qm9)})\n"
|
| 590 |
+
]
|
| 591 |
+
}
|
| 592 |
+
],
|
| 593 |
+
"metadata": {
|
| 594 |
+
"kernelspec": {
|
| 595 |
+
"display_name": "Python 3",
|
| 596 |
+
"language": "python",
|
| 597 |
+
"name": "python3"
|
| 598 |
+
},
|
| 599 |
+
"language_info": {
|
| 600 |
+
"name": "python",
|
| 601 |
+
"pygments_lexer": "ipython3"
|
| 602 |
+
}
|
| 603 |
+
},
|
| 604 |
+
"nbformat": 4,
|
| 605 |
+
"nbformat_minor": 5
|
| 606 |
+
}
|