D4CMPP2 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. d4cmpp2-0.4.0/D4CMPP2.egg-info/PKG-INFO +420 -0
  2. d4cmpp2-0.4.0/D4CMPP2.egg-info/SOURCES.txt +273 -0
  3. d4cmpp2-0.4.0/D4CMPP2.egg-info/dependency_links.txt +1 -0
  4. d4cmpp2-0.4.0/D4CMPP2.egg-info/entry_points.txt +2 -0
  5. d4cmpp2-0.4.0/D4CMPP2.egg-info/requires.txt +16 -0
  6. d4cmpp2-0.4.0/D4CMPP2.egg-info/top_level.txt +1 -0
  7. d4cmpp2-0.4.0/LICENSE +21 -0
  8. d4cmpp2-0.4.0/MANIFEST.in +10 -0
  9. d4cmpp2-0.4.0/PKG-INFO +420 -0
  10. d4cmpp2-0.4.0/README.md +395 -0
  11. d4cmpp2-0.4.0/_Data/AGENTS.md +24 -0
  12. d4cmpp2-0.4.0/_Data/Aqsoldb.csv +9291 -0
  13. d4cmpp2-0.4.0/_Data/BradleyMP.csv +3042 -0
  14. d4cmpp2-0.4.0/_Data/Lipophilicity.csv +1131 -0
  15. d4cmpp2-0.4.0/_Data/README.md +8 -0
  16. d4cmpp2-0.4.0/_Data/__init__.py +26 -0
  17. d4cmpp2-0.4.0/_Data/optical.csv +20237 -0
  18. d4cmpp2-0.4.0/_Data/test.csv +190 -0
  19. d4cmpp2-0.4.0/__init__.py +16 -0
  20. d4cmpp2-0.4.0/__main__.py +5 -0
  21. d4cmpp2-0.4.0/_main.py +500 -0
  22. d4cmpp2-0.4.0/cli.py +7 -0
  23. d4cmpp2-0.4.0/examples/AGENTS.md +29 -0
  24. d4cmpp2-0.4.0/examples/ISA/segment.py +8 -0
  25. d4cmpp2-0.4.0/examples/README.md +81 -0
  26. d4cmpp2-0.4.0/examples/assets/tiny_numeric.csv +16 -0
  27. d4cmpp2-0.4.0/examples/cli/README.md +33 -0
  28. d4cmpp2-0.4.0/examples/custom_network.py +84 -0
  29. d4cmpp2-0.4.0/examples/experiments/01_compare.py +26 -0
  30. d4cmpp2-0.4.0/examples/experiments/02_optimize.py +51 -0
  31. d4cmpp2-0.4.0/examples/experiments/03_legacy_grid_search.py +23 -0
  32. d4cmpp2-0.4.0/examples/extensions/01_callbacks.py +27 -0
  33. d4cmpp2-0.4.0/examples/extensions/02_custom_network_training.py +30 -0
  34. d4cmpp2-0.4.0/examples/extensions/03_numeric_inputs.py +95 -0
  35. d4cmpp2-0.4.0/examples/inference/01_prediction.py +26 -0
  36. d4cmpp2-0.4.0/examples/inference/02_csv_prediction.py +30 -0
  37. d4cmpp2-0.4.0/examples/inference/03_uncertainty_ensemble.py +41 -0
  38. d4cmpp2-0.4.0/examples/inference/04_isa_interpretation.py +37 -0
  39. d4cmpp2-0.4.0/examples/training/01_basic_cpu.py +24 -0
  40. d4cmpp2-0.4.0/examples/training/02_solvent.py +20 -0
  41. d4cmpp2-0.4.0/examples/training/03_multitarget.py +20 -0
  42. d4cmpp2-0.4.0/examples/training/04_splitting_reproducibility.py +25 -0
  43. d4cmpp2-0.4.0/examples/training/05_isa.py +22 -0
  44. d4cmpp2-0.4.0/examples/training/06_saved_model_modes.py +45 -0
  45. d4cmpp2-0.4.0/examples/training/07_model_families.py +42 -0
  46. d4cmpp2-0.4.0/exceptions.py +53 -0
  47. d4cmpp2-0.4.0/grid_search.py +259 -0
  48. d4cmpp2-0.4.0/network_refer.yaml +160 -0
  49. d4cmpp2-0.4.0/networks/AFP_model.py +72 -0
  50. d4cmpp2-0.4.0/networks/AFPwithSolv_model.py +72 -0
  51. d4cmpp2-0.4.0/networks/DMPNN_model.py +90 -0
  52. d4cmpp2-0.4.0/networks/DMPNNwithSolv_model.py +89 -0
  53. d4cmpp2-0.4.0/networks/GAT_model.py +48 -0
  54. d4cmpp2-0.4.0/networks/GATwithSolv_model.py +63 -0
  55. d4cmpp2-0.4.0/networks/GCN_model.py +113 -0
  56. d4cmpp2-0.4.0/networks/GCNwithSolv_model.py +103 -0
  57. d4cmpp2-0.4.0/networks/GC_model.py +122 -0
  58. d4cmpp2-0.4.0/networks/ISATPM_model.py +14 -0
  59. d4cmpp2-0.4.0/networks/ISATPN_model.py +199 -0
  60. d4cmpp2-0.4.0/networks/ISAT_model.py +90 -0
  61. d4cmpp2-0.4.0/networks/MPNN_model.py +56 -0
  62. d4cmpp2-0.4.0/networks/MPNNwithSolv_model.py +72 -0
  63. d4cmpp2-0.4.0/networks/__init__.py +25 -0
  64. d4cmpp2-0.4.0/networks/base.py +250 -0
  65. d4cmpp2-0.4.0/networks/registry.py +187 -0
  66. d4cmpp2-0.4.0/networks/src/AFP.py +118 -0
  67. d4cmpp2-0.4.0/networks/src/BiDropout.py +29 -0
  68. d4cmpp2-0.4.0/networks/src/DMPNN.py +35 -0
  69. d4cmpp2-0.4.0/networks/src/GAT.py +69 -0
  70. d4cmpp2-0.4.0/networks/src/GC.py +85 -0
  71. d4cmpp2-0.4.0/networks/src/GCN.py +71 -0
  72. d4cmpp2-0.4.0/networks/src/ISAT.py +153 -0
  73. d4cmpp2-0.4.0/networks/src/Linear.py +49 -0
  74. d4cmpp2-0.4.0/networks/src/MPNN.py +56 -0
  75. d4cmpp2-0.4.0/networks/src/SolventLayer.py +62 -0
  76. d4cmpp2-0.4.0/networks/src/__init__.py +0 -0
  77. d4cmpp2-0.4.0/networks/src/distGCN.py +21 -0
  78. d4cmpp2-0.4.0/networks/src/pyg_hetero.py +24 -0
  79. d4cmpp2-0.4.0/optimize.py +472 -0
  80. d4cmpp2-0.4.0/pyproject.toml +53 -0
  81. d4cmpp2-0.4.0/setup.cfg +4 -0
  82. d4cmpp2-0.4.0/src/Analyzer/ISAAnalyzer.py +458 -0
  83. d4cmpp2-0.4.0/src/Analyzer/ISAPNAnalyzer.py +366 -0
  84. d4cmpp2-0.4.0/src/Analyzer/ISAwSAnalyzer.py +117 -0
  85. d4cmpp2-0.4.0/src/Analyzer/MolAnalyzer.py +319 -0
  86. d4cmpp2-0.4.0/src/Analyzer/__init__.py +54 -0
  87. d4cmpp2-0.4.0/src/Analyzer/core.py +480 -0
  88. d4cmpp2-0.4.0/src/Analyzer/factory.py +166 -0
  89. d4cmpp2-0.4.0/src/Analyzer/interpretation.py +232 -0
  90. d4cmpp2-0.4.0/src/Analyzer/results.py +101 -0
  91. d4cmpp2-0.4.0/src/DataManager/Dataset/GraphDataset.py +314 -0
  92. d4cmpp2-0.4.0/src/DataManager/Dataset/ISAGraphDataset.py +384 -0
  93. d4cmpp2-0.4.0/src/DataManager/Dataset/__init__.py +0 -0
  94. d4cmpp2-0.4.0/src/DataManager/GraphGenerator/ISAGraphGenerator.py +223 -0
  95. d4cmpp2-0.4.0/src/DataManager/GraphGenerator/MolGraphGenerator.py +73 -0
  96. d4cmpp2-0.4.0/src/DataManager/GraphGenerator/__init__.py +14 -0
  97. d4cmpp2-0.4.0/src/DataManager/ISADataManager.py +67 -0
  98. d4cmpp2-0.4.0/src/DataManager/MolDataManager.py +735 -0
  99. d4cmpp2-0.4.0/src/DataManager/__init__.py +14 -0
  100. d4cmpp2-0.4.0/src/DataManager/contracts.py +179 -0
  101. d4cmpp2-0.4.0/src/NetworkManager/ISANetworkManager.py +12 -0
  102. d4cmpp2-0.4.0/src/NetworkManager/NetworkManager.py +520 -0
  103. d4cmpp2-0.4.0/src/NetworkManager/__init__.py +14 -0
  104. d4cmpp2-0.4.0/src/PostProcessor.py +160 -0
  105. d4cmpp2-0.4.0/src/TrainManager/ISATrainManager.py +26 -0
  106. d4cmpp2-0.4.0/src/TrainManager/TrainManager.py +254 -0
  107. d4cmpp2-0.4.0/src/TrainManager/__init__.py +14 -0
  108. d4cmpp2-0.4.0/src/TrainManager/callbacks.py +119 -0
  109. d4cmpp2-0.4.0/src/__init__.py +0 -0
  110. d4cmpp2-0.4.0/src/utils/PATH.py +246 -0
  111. d4cmpp2-0.4.0/src/utils/__init__.py +0 -0
  112. d4cmpp2-0.4.0/src/utils/argparser.py +56 -0
  113. d4cmpp2-0.4.0/src/utils/checkpointing.py +90 -0
  114. d4cmpp2-0.4.0/src/utils/config_resolution.py +123 -0
  115. d4cmpp2-0.4.0/src/utils/config_validation.py +370 -0
  116. d4cmpp2-0.4.0/src/utils/csv_validation.py +105 -0
  117. d4cmpp2-0.4.0/src/utils/data_quality.py +181 -0
  118. d4cmpp2-0.4.0/src/utils/featureizer.py +202 -0
  119. d4cmpp2-0.4.0/src/utils/functional_group.csv +169 -0
  120. d4cmpp2-0.4.0/src/utils/graph_cache.py +213 -0
  121. d4cmpp2-0.4.0/src/utils/leaderboard.py +212 -0
  122. d4cmpp2-0.4.0/src/utils/metrics.py +31 -0
  123. d4cmpp2-0.4.0/src/utils/module_loader.py +147 -0
  124. d4cmpp2-0.4.0/src/utils/output.py +80 -0
  125. d4cmpp2-0.4.0/src/utils/reproducibility.py +70 -0
  126. d4cmpp2-0.4.0/src/utils/run_manifest.py +175 -0
  127. d4cmpp2-0.4.0/src/utils/scaler.py +40 -0
  128. d4cmpp2-0.4.0/src/utils/sculptor.py +713 -0
  129. d4cmpp2-0.4.0/src/utils/splitting.py +250 -0
  130. d4cmpp2-0.4.0/src/utils/supportfile_saver.py +94 -0
  131. d4cmpp2-0.4.0/src/utils/tools.py +156 -0
  132. d4cmpp2-0.4.0/src/utils/transfer_learning.py +111 -0
  133. d4cmpp2-0.4.0/tests/test_cli_packaging.py +53 -0
  134. d4cmpp2-0.4.0/tests/test_config_validation.py +184 -0
  135. d4cmpp2-0.4.0/tests/test_csv_data_manager_validation.py +120 -0
  136. d4cmpp2-0.4.0/tests/test_csv_validation.py +60 -0
  137. d4cmpp2-0.4.0/tests/test_custom_network.py +83 -0
  138. d4cmpp2-0.4.0/tests/test_data_fixture.py +28 -0
  139. d4cmpp2-0.4.0/tests/test_example_model_compatibility.py +203 -0
  140. d4cmpp2-0.4.0/tests/test_examples_syntax.py +62 -0
  141. d4cmpp2-0.4.0/tests/test_failure_behavior.py +159 -0
  142. d4cmpp2-0.4.0/tests/test_failure_contracts.py +84 -0
  143. d4cmpp2-0.4.0/tests/test_gcn_end_to_end.py +214 -0
  144. d4cmpp2-0.4.0/tests/test_graph_alignment.py +114 -0
  145. d4cmpp2-0.4.0/tests/test_heavy_smoke.py +31 -0
  146. d4cmpp2-0.4.0/tests/test_network_abc.py +48 -0
  147. d4cmpp2-0.4.0/tests/test_network_persistence.py +100 -0
  148. d4cmpp2-0.4.0/tests/test_optimize.py +173 -0
  149. d4cmpp2-0.4.0/tests/test_path_utils.py +209 -0
  150. d4cmpp2-0.4.0/tests/test_public_contracts.py +221 -0
  151. d4cmpp2-0.4.0/tests/test_pyg_data_contract.py +253 -0
  152. d4cmpp2-0.4.0/tests/test_pyg_dmpnn_afp.py +83 -0
  153. d4cmpp2-0.4.0/tests/test_pyg_gcn.py +110 -0
  154. d4cmpp2-0.4.0/tests/test_pyg_isa_models.py +141 -0
  155. d4cmpp2-0.4.0/tests/test_pyg_mpnn_gat.py +105 -0
  156. d4cmpp2-0.4.0/tests/test_runtime_environment.py +94 -0
  157. d4cmpp2-0.4.0/tests/test_scaler_alignment.py +86 -0
  158. d4cmpp2-0.4.0/tests/test_state_dict_contract.py +54 -0
  159. d4cmpp2-0.4.0/tests/test_t3_checkpoint_policy.py +311 -0
  160. d4cmpp2-0.4.0/tests/test_t3_data_quality.py +89 -0
  161. d4cmpp2-0.4.0/tests/test_t3_dataset_contract_matrix.py +217 -0
  162. d4cmpp2-0.4.0/tests/test_t3_graph_cache_integrity.py +135 -0
  163. d4cmpp2-0.4.0/tests/test_t3_grid_search.py +175 -0
  164. d4cmpp2-0.4.0/tests/test_t3_leaderboard.py +94 -0
  165. d4cmpp2-0.4.0/tests/test_t3_registry_smoke_matrix.py +156 -0
  166. d4cmpp2-0.4.0/tests/test_t3_reproducibility.py +88 -0
  167. d4cmpp2-0.4.0/tests/test_t3_run_manifest.py +58 -0
  168. d4cmpp2-0.4.0/tests/test_t3_scaffold_split.py +128 -0
  169. d4cmpp2-0.4.0/tests/test_t3_transfer_learning.py +151 -0
  170. d4cmpp2-0.4.0/tests/test_t4_analyzer_core.py +388 -0
  171. d4cmpp2-0.4.0/tests/test_t5_callbacks.py +205 -0
  172. d4cmpp2-0.4.0/tests/test_t5_config_resolution.py +218 -0
  173. d4cmpp2-0.4.0/tests/test_t5_errors_logging.py +155 -0
  174. d4cmpp2-0.4.0/tests/test_t5_import_discovery.py +87 -0
  175. d4cmpp2-0.4.0/tests/test_t5_manager_contracts.py +130 -0
  176. d4cmpp2-0.4.0/tests/test_t5_verbose_output.py +81 -0
  177. d4cmpp2-0.4.0/tests/test_t6_ci_contract.py +98 -0
  178. d4cmpp2-0.4.0/tests/test_t7_cycle_audit.py +66 -0
@@ -0,0 +1,420 @@
1
+ Metadata-Version: 2.4
2
+ Name: D4CMPP2
3
+ Version: 0.4.0
4
+ Summary: PyTorch Geometric molecular property prediction models
5
+ License-Expression: MIT
6
+ Requires-Python: <3.13,>=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: torch<3,>=2.2
10
+ Requires-Dist: torch-geometric<3,>=2.8
11
+ Requires-Dist: numpy>=1.24
12
+ Requires-Dist: pandas>=2.0
13
+ Requires-Dist: matplotlib>=3.7
14
+ Requires-Dist: tqdm>=4.65
15
+ Requires-Dist: prettytable>=3.9
16
+ Requires-Dist: rdkit>=2023.9
17
+ Requires-Dist: scikit-learn>=1.3
18
+ Requires-Dist: Pillow>=10
19
+ Requires-Dist: PyYAML>=6
20
+ Requires-Dist: MoleculeSculptor<2,>=1.0.1
21
+ Provides-Extra: notebook
22
+ Requires-Dist: jupyterlab>=4; extra == "notebook"
23
+ Requires-Dist: ipywidgets>=8; extra == "notebook"
24
+ Dynamic: license-file
25
+
26
+ # D4CMPP2
27
+
28
+ D4CMPP2 is a PyTorch Geometric package for molecular-property regression. It
29
+ supports ordinary molecular graphs, compound/solvent pairs, and interpretable
30
+ ISA models through one training and inference API.
31
+
32
+ ## Requirements and installation
33
+
34
+ Supported runtime:
35
+
36
+ - Python 3.10-3.12
37
+ - PyTorch `>=2.2,<3`
38
+ - PyTorch Geometric `>=2.8,<3`
39
+ - Linux and Windows
40
+ - CPU, or CUDA with a matching PyTorch build
41
+
42
+ Install the appropriate PyTorch build for the machine first, then install
43
+ D4CMPP2:
44
+
45
+ ```sh
46
+ python -m pip install D4CMPP2
47
+ ```
48
+
49
+ Notebook extras are optional:
50
+
51
+ ```sh
52
+ python -m pip install "D4CMPP2[notebook]"
53
+ ```
54
+
55
+ DGL is not installed or loaded. DGL graph caches cannot be renamed or reused
56
+ as PyG caches.
57
+
58
+ ## Supported models
59
+
60
+ | Family | Network IDs |
61
+ |---|---|
62
+ | General | `GCN`, `MPNN`, `DMPNN`, `AFP`, `GAT` |
63
+ | With solvent | `GCNwS`, `MPNNwS`, `DMPNNwS`, `AFPwS`, `GATwS` |
64
+ | ISA | `GC`, `ISAT`, `ISATPN` |
65
+
66
+ `AGC`, `MegNet`, `MegNetwS`, `ALIGNN`, and `ALIGNNwS` are not part of the
67
+ PyG-only release.
68
+
69
+ ## Input data
70
+
71
+ A general model needs a `compound` SMILES column and one or more numeric target
72
+ columns. A `wS` model additionally needs a `solvent` SMILES column:
73
+
74
+ ```csv
75
+ compound,solvent,Solubility
76
+ CCO,O,-0.31
77
+ CCN,CO,-0.18
78
+ ```
79
+
80
+ Useful optional columns and arguments:
81
+
82
+ - `set`: predefined `train`, `val`, and `test` labels.
83
+ - `numeric_input_columns`: additional finite numeric model inputs.
84
+ - `molecule_columns`: molecule columns in their model input order.
85
+ - `explicit_h_columns`: molecule columns that require explicit hydrogens.
86
+
87
+ Without a `set` column, the default split is a seeded 80/10/10 random split.
88
+ Invalid SMILES, missing columns, non-numeric inputs, all-NaN targets, and
89
+ misaligned arrays fail with the affected path, column, value, or row.
90
+
91
+ ## Quickstart
92
+
93
+ The package includes a small `test.csv`. Run a two-epoch CPU smoke training:
94
+
95
+ ```sh
96
+ d4cmpp2 --data test --target Abs --network GCN --device cpu --epoch 2
97
+ ```
98
+
99
+ Equivalent Python:
100
+
101
+ ```python
102
+ from D4CMPP2 import train
103
+
104
+ model_path = train(
105
+ data="test",
106
+ target=["Abs"],
107
+ network="GCN",
108
+ device="cpu",
109
+ max_epoch=2,
110
+ batch_size=4,
111
+ )
112
+ print(model_path)
113
+ ```
114
+
115
+ Runnable examples for training, solvent and ISA models, saved-model modes,
116
+ inference, uncertainty, optimization, callbacks, custom networks, and the CLI
117
+ are indexed in [`examples/README.md`](examples/README.md).
118
+
119
+ For GPU training, use `device="cuda:0"` or `--device cuda:0`. D4CMPP2 validates
120
+ the requested index and does not silently fall back to CPU.
121
+
122
+ ### Solvent and ISA
123
+
124
+ ```python
125
+ from D4CMPP2 import train
126
+
127
+ solvent_model = train(
128
+ data="solvent_data.csv",
129
+ target=["Solubility"],
130
+ network="GCNwS",
131
+ molecule_columns=["compound", "solvent"],
132
+ device="cpu",
133
+ )
134
+
135
+ isa_model = train(
136
+ data="Aqsoldb",
137
+ target=["Solubility"],
138
+ network="ISATPN",
139
+ sculptor_index=(6, 2, 0),
140
+ device="cpu",
141
+ )
142
+ ```
143
+
144
+ `sculptor_index=(split, combine, absorb)` controls ISA fragmentation. Existing
145
+ fragment rules and saved `functional_group.csv` files are part of the model
146
+ contract.
147
+
148
+ ## Training behavior
149
+
150
+ The most important defaults are:
151
+
152
+ | Key | Default |
153
+ |---|---|
154
+ | `batch_size` | `256` |
155
+ | `max_epoch` | `2000` |
156
+ | `optimizer` | `"Adam"` |
157
+ | `learning_rate` | `0.001` |
158
+ | `weight_decay` | `0.0005` |
159
+ | `device` | `"cuda:0"` |
160
+ | `scaler` | `"standard"` |
161
+ | `verbose` | `True` |
162
+
163
+ Configuration is resolved into an isolated working copy. Historical precedence
164
+ is retained for numerical compatibility:
165
+
166
+ | Mode | Lower to higher precedence |
167
+ |---|---|
168
+ | Scratch | defaults, API/CLI, registry |
169
+ | Full resume | saved config, explicit resume overrides |
170
+ | `LOAD_PATH` continue | saved config, current defaults/API |
171
+ | Transfer | source config, current defaults/API, registry |
172
+ | Optimization trial | resolved base, trial values |
173
+
174
+ Unknown keys remain available to legacy configs and custom implementations.
175
+ Resolved provenance is written to the run manifest without changing
176
+ `config.yaml`.
177
+
178
+ ### Splitting and reproducibility
179
+
180
+ `split_strategy` accepts:
181
+
182
+ - `"auto"`: use `set` when present, otherwise random 80/10/10.
183
+ - `"random"`: always use row-level random splitting.
184
+ - `"predefined"`: require the `set` column.
185
+ - `"scaffold"`: keep RDKit Murcko-scaffold groups within one split.
186
+
187
+ Normal runs write `split_report.json` and `split_assignments.csv`.
188
+
189
+ ```python
190
+ model_path = train(
191
+ data="Aqsoldb",
192
+ target=["Solubility"],
193
+ network="GCN",
194
+ random_seed=42,
195
+ split_random_seed=42,
196
+ deterministic_algorithms=True,
197
+ device="cpu",
198
+ )
199
+ ```
200
+
201
+ `random_seed` controls Python, NumPy, torch/CUDA, shuffle, DataLoader workers,
202
+ dropout, and partial-training selection. `split_random_seed` controls only the
203
+ data split. Deterministic algorithms may reduce GPU performance or reject an
204
+ unsupported operation.
205
+
206
+ ### Resume, continue, and transfer
207
+
208
+ The three saved-model modes are mutually exclusive:
209
+
210
+ - `RESUME_PATH` or `--resume`: exact full-state resume from
211
+ `checkpoints/latest.ckpt`.
212
+ - `LOAD_PATH` or `--load`: load `final.pth` but reset optimizer, schedulers,
213
+ epoch, and RNG.
214
+ - `TRANSFER_PATH` or `--transfer`: copy compatible same-name/same-shape
215
+ parameters into a new model.
216
+
217
+ Full checkpoints preserve optimizer, both schedulers, epoch, best metric,
218
+ early-stopping state, and RNG state. Transfer writes `transfer_report.json`
219
+ with loaded and skipped parameters plus the source weight hash.
220
+
221
+ ### Outputs and caches
222
+
223
+ Training returns the model directory, normally below `./_Models/`. Important
224
+ artifacts include:
225
+
226
+ - `config.yaml`, `network.py`, `final.pth`, `scaler.pkl`
227
+ - `network_identity.json`, `model_summary.txt`
228
+ - `checkpoints/latest.ckpt`, `checkpoints/best.ckpt`
229
+ - `runs/<run_id>/run_manifest.json`
230
+ - `result/prediction.csv`, metrics, curves, and plots
231
+ - data-quality and split reports
232
+
233
+ Graph caches are atomic, fingerprinted PyG schema-v2 files. Identity includes
234
+ ordered SMILES, feature dimensions, explicit-hydrogen settings, and ISA rules.
235
+ The cache policies are:
236
+
237
+ - `"v2"`: validate the current cache and fail clearly if it is incompatible.
238
+ - `"regenerate"`: rebuild an invalid v2 cache from the source CSV.
239
+ - `"legacy"`: explicitly load a compatible PyG v1 cache with a warning.
240
+
241
+ DGL caches are preserved but never loaded.
242
+
243
+ ## Prediction and analysis
244
+
245
+ ```python
246
+ from D4CMPP2 import Analyzer
247
+
248
+ analyzer = Analyzer(model_path, device="cpu", save_result=False)
249
+ print(analyzer.predict(["CCO", "CCN"]))
250
+ ```
251
+
252
+ `Analyzer` reads the saved config and selects the general, solvent, or ISA
253
+ implementation. It requires `config.yaml`, `network.py`, and `final.pth`;
254
+ non-identity scaling also requires `scaler.pkl`, and ISA requires the saved
255
+ `functional_group.csv`. Load pickle-based artifacts only from trusted model
256
+ folders.
257
+
258
+ Use row-preserving inference when duplicates or invalid inputs matter:
259
+
260
+ ```python
261
+ result = analyzer.predict_rows(
262
+ compound=["CCO", "CCO", "not-a-smiles"],
263
+ )
264
+ print(result.to_dataframe())
265
+ ```
266
+
267
+ Every row retains its original index, inputs, prediction, status, and error.
268
+ Solvent and numeric-input models require every saved input column with equal
269
+ length:
270
+
271
+ ```python
272
+ result = analyzer.predict_rows(
273
+ compound=["CCO", "CCN"],
274
+ solvent=["O", "CO"],
275
+ temperature=[298.0, 310.0],
276
+ )
277
+ ```
278
+
279
+ CSV inference preserves source rows and commits the output atomically:
280
+
281
+ ```python
282
+ output_path = analyzer.predict_csv(
283
+ "molecules.csv",
284
+ "molecules_prediction.csv",
285
+ uncertainty_samples=30,
286
+ uncertainty_seed=42,
287
+ )
288
+ ```
289
+
290
+ `predict_uncertainty()` uses MC dropout and `Analyzer.predict_ensemble()` uses
291
+ compatible independently trained models. Their standard deviations are model
292
+ dispersion estimates, not calibrated prediction intervals.
293
+
294
+ ISA analyzers also provide `analyze_rows()` and `plot_analysis()`. Fragment
295
+ indices are validated against atom alignment before scores or features are
296
+ returned.
297
+
298
+ ## Experiment comparison and optimization
299
+
300
+ ```python
301
+ from D4CMPP2 import compare_experiments
302
+
303
+ leaderboard = compare_experiments(
304
+ ["./_Models"],
305
+ output_path="leaderboard.csv",
306
+ metric="val_rmse",
307
+ )
308
+ ```
309
+
310
+ Ranking is calculated separately per target. Legacy, failed, and interrupted
311
+ runs remain visible without borrowing another run's metrics.
312
+
313
+ For new hyperparameter searches, use the model-aware API:
314
+
315
+ ```python
316
+ import D4CMPP2
317
+
318
+ result = D4CMPP2.optimize(
319
+ data="Aqsoldb.csv",
320
+ target=["Solubility"],
321
+ network="GCN",
322
+ HP=["hidden_dim", "dropout"],
323
+ optimize_strategy="bayesian",
324
+ n_trials=20,
325
+ device="cpu",
326
+ )
327
+ print(result.best_params, result.best_model_path)
328
+ ```
329
+
330
+ `HP=None` uses the model's default optimization space. A key list uses declared
331
+ model ranges; a dictionary supplies categorical values or numeric ranges.
332
+ Supported strategies are `"bayesian"` and `"grid"`. Atomic JSON/CSV summaries
333
+ and trial directories allow compatible searches to resume.
334
+
335
+ The legacy `grid_search()` API remains available with its historical `None`
336
+ return value and continue-on-trial-error behavior.
337
+
338
+ ## Callbacks and custom networks
339
+
340
+ Observation-only training callbacks are runtime objects and are not saved:
341
+
342
+ ```python
343
+ from D4CMPP2 import train
344
+ from D4CMPP2.src.TrainManager.callbacks import EventHistory
345
+
346
+ history = EventHistory()
347
+ model_path = train(
348
+ data="test",
349
+ target=["Abs"],
350
+ network="GCN",
351
+ device="cpu",
352
+ callbacks=[history],
353
+ )
354
+ ```
355
+
356
+ Callbacks receive immutable run/epoch/validation/checkpoint/error events. A
357
+ callback failure stops training and preserves the original failure contract.
358
+
359
+ Custom models subclass `D4CMPP2.MolecularNetwork`, declare `model_name`,
360
+ `input_contract`, hyperparameters, and optionally `compute_loss()`, then call:
361
+
362
+ ```python
363
+ D4CMPP2.register_network(CustomGCN, data_contract="molecule")
364
+ ```
365
+
366
+ Available data contracts are `"molecule"`, `"solvent"`, and `"isa"`. Define
367
+ the class at module scope in an importable file. Training copies that source to
368
+ the model directory as `network.py`; reload and transfer prefer the saved
369
+ snapshot. See `examples/custom_network.py` for a complete implementation.
370
+
371
+ ## CLI
372
+
373
+ ```sh
374
+ python -m D4CMPP2 --help
375
+ d4cmpp2 --help
376
+ ```
377
+
378
+ Target columns are comma-separated. `--quiet` hides routine information and
379
+ progress but not warnings or errors. `--cuda 0` remains a deprecated alias for
380
+ `--device cuda:0`.
381
+
382
+ ## Migration and compatibility
383
+
384
+ - Public `train`, `grid_search`, `Analyzer`, `Segmentator`, and `Data` names
385
+ remain available.
386
+ - New runs fit the target scaler on training rows by default. Old configs
387
+ without the policy retain historical full-data scaling with a warning.
388
+ - The loader prefers the saved model folder's `network.py`, config, weights,
389
+ scaler, and ISA rules over obsolete absolute paths.
390
+ - The historical `ISATPM` saved name is supported through the `ISATPN`
391
+ compatibility adapter.
392
+ - Keep DGL-era models and caches with their original environment for archival
393
+ reproduction. Automatic conversion is not provided.
394
+ - Package version and saved-model/config contract version are separate.
395
+
396
+ Public API or saved-asset compatibility breaks require a major release.
397
+ Deprecations should include a warning and a migration path.
398
+
399
+ ## Troubleshooting
400
+
401
+ - `torch_geometric` import failure: install torch and PyG builds compatible
402
+ with the same Python and CPU/CUDA runtime.
403
+ - CUDA unavailable or index out of range: select an existing `cuda:N` or use
404
+ `device="cpu"` explicitly.
405
+ - Missing target/SMILES column: compare the reported available columns with the
406
+ configured target and molecule columns.
407
+ - Invalid SMILES: fix or remove the reported rows; related arrays share one
408
+ alignment mask.
409
+ - Cache shape or recipe mismatch: use the source CSV with
410
+ `graph_cache_policy="regenerate"` after reviewing the diagnostic.
411
+ - Model path missing or ambiguous: pass the exact saved-model directory.
412
+ - Old model fails to load: preserve the complete folder and original
413
+ environment; report config, package versions, and the error without sharing
414
+ private data.
415
+
416
+ ## Repository maintenance
417
+
418
+ Implementation contracts, compatibility constraints, validation commands, and
419
+ change notes live in the nearest `AGENTS.md` file within each source area.
420
+ Read the workspace and nearest folder instructions before modifying code.
@@ -0,0 +1,273 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ __init__.py
5
+ __main__.py
6
+ _main.py
7
+ cli.py
8
+ exceptions.py
9
+ grid_search.py
10
+ network_refer.yaml
11
+ optimize.py
12
+ pyproject.toml
13
+ ./__init__.py
14
+ ./__main__.py
15
+ ./_main.py
16
+ ./cli.py
17
+ ./exceptions.py
18
+ ./grid_search.py
19
+ ./network_refer.yaml
20
+ ./optimize.py
21
+ ./_Data/AGENTS.md
22
+ ./_Data/Aqsoldb.csv
23
+ ./_Data/BradleyMP.csv
24
+ ./_Data/Lipophilicity.csv
25
+ ./_Data/README.md
26
+ ./_Data/__init__.py
27
+ ./_Data/optical.csv
28
+ ./_Data/test.csv
29
+ ./networks/AFP_model.py
30
+ ./networks/AFPwithSolv_model.py
31
+ ./networks/DMPNN_model.py
32
+ ./networks/DMPNNwithSolv_model.py
33
+ ./networks/GAT_model.py
34
+ ./networks/GATwithSolv_model.py
35
+ ./networks/GCN_model.py
36
+ ./networks/GCNwithSolv_model.py
37
+ ./networks/GC_model.py
38
+ ./networks/ISATPM_model.py
39
+ ./networks/ISATPN_model.py
40
+ ./networks/ISAT_model.py
41
+ ./networks/MPNN_model.py
42
+ ./networks/MPNNwithSolv_model.py
43
+ ./networks/__init__.py
44
+ ./networks/base.py
45
+ ./networks/registry.py
46
+ ./networks/src/AFP.py
47
+ ./networks/src/BiDropout.py
48
+ ./networks/src/DMPNN.py
49
+ ./networks/src/GAT.py
50
+ ./networks/src/GC.py
51
+ ./networks/src/GCN.py
52
+ ./networks/src/ISAT.py
53
+ ./networks/src/Linear.py
54
+ ./networks/src/MPNN.py
55
+ ./networks/src/SolventLayer.py
56
+ ./networks/src/__init__.py
57
+ ./networks/src/distGCN.py
58
+ ./networks/src/pyg_hetero.py
59
+ ./src/PostProcessor.py
60
+ ./src/__init__.py
61
+ ./src/Analyzer/ISAAnalyzer.py
62
+ ./src/Analyzer/ISAPNAnalyzer.py
63
+ ./src/Analyzer/ISAwSAnalyzer.py
64
+ ./src/Analyzer/MolAnalyzer.py
65
+ ./src/Analyzer/__init__.py
66
+ ./src/Analyzer/core.py
67
+ ./src/Analyzer/factory.py
68
+ ./src/Analyzer/interpretation.py
69
+ ./src/Analyzer/results.py
70
+ ./src/DataManager/ISADataManager.py
71
+ ./src/DataManager/MolDataManager.py
72
+ ./src/DataManager/__init__.py
73
+ ./src/DataManager/contracts.py
74
+ ./src/DataManager/Dataset/GraphDataset.py
75
+ ./src/DataManager/Dataset/ISAGraphDataset.py
76
+ ./src/DataManager/Dataset/__init__.py
77
+ ./src/DataManager/GraphGenerator/ISAGraphGenerator.py
78
+ ./src/DataManager/GraphGenerator/MolGraphGenerator.py
79
+ ./src/DataManager/GraphGenerator/__init__.py
80
+ ./src/NetworkManager/ISANetworkManager.py
81
+ ./src/NetworkManager/NetworkManager.py
82
+ ./src/NetworkManager/__init__.py
83
+ ./src/TrainManager/ISATrainManager.py
84
+ ./src/TrainManager/TrainManager.py
85
+ ./src/TrainManager/__init__.py
86
+ ./src/TrainManager/callbacks.py
87
+ ./src/utils/PATH.py
88
+ ./src/utils/__init__.py
89
+ ./src/utils/argparser.py
90
+ ./src/utils/checkpointing.py
91
+ ./src/utils/config_resolution.py
92
+ ./src/utils/config_validation.py
93
+ ./src/utils/csv_validation.py
94
+ ./src/utils/data_quality.py
95
+ ./src/utils/featureizer.py
96
+ ./src/utils/functional_group.csv
97
+ ./src/utils/graph_cache.py
98
+ ./src/utils/leaderboard.py
99
+ ./src/utils/metrics.py
100
+ ./src/utils/module_loader.py
101
+ ./src/utils/output.py
102
+ ./src/utils/reproducibility.py
103
+ ./src/utils/run_manifest.py
104
+ ./src/utils/scaler.py
105
+ ./src/utils/sculptor.py
106
+ ./src/utils/splitting.py
107
+ ./src/utils/supportfile_saver.py
108
+ ./src/utils/tools.py
109
+ ./src/utils/transfer_learning.py
110
+ D4CMPP2.egg-info/PKG-INFO
111
+ D4CMPP2.egg-info/SOURCES.txt
112
+ D4CMPP2.egg-info/dependency_links.txt
113
+ D4CMPP2.egg-info/entry_points.txt
114
+ D4CMPP2.egg-info/requires.txt
115
+ D4CMPP2.egg-info/top_level.txt
116
+ _Data/AGENTS.md
117
+ _Data/Aqsoldb.csv
118
+ _Data/BradleyMP.csv
119
+ _Data/Lipophilicity.csv
120
+ _Data/README.md
121
+ _Data/__init__.py
122
+ _Data/optical.csv
123
+ _Data/test.csv
124
+ examples/AGENTS.md
125
+ examples/README.md
126
+ examples/custom_network.py
127
+ examples/ISA/segment.py
128
+ examples/assets/tiny_numeric.csv
129
+ examples/cli/README.md
130
+ examples/experiments/01_compare.py
131
+ examples/experiments/02_optimize.py
132
+ examples/experiments/03_legacy_grid_search.py
133
+ examples/extensions/01_callbacks.py
134
+ examples/extensions/02_custom_network_training.py
135
+ examples/extensions/03_numeric_inputs.py
136
+ examples/inference/01_prediction.py
137
+ examples/inference/02_csv_prediction.py
138
+ examples/inference/03_uncertainty_ensemble.py
139
+ examples/inference/04_isa_interpretation.py
140
+ examples/training/01_basic_cpu.py
141
+ examples/training/02_solvent.py
142
+ examples/training/03_multitarget.py
143
+ examples/training/04_splitting_reproducibility.py
144
+ examples/training/05_isa.py
145
+ examples/training/06_saved_model_modes.py
146
+ examples/training/07_model_families.py
147
+ networks/AFP_model.py
148
+ networks/AFPwithSolv_model.py
149
+ networks/DMPNN_model.py
150
+ networks/DMPNNwithSolv_model.py
151
+ networks/GAT_model.py
152
+ networks/GATwithSolv_model.py
153
+ networks/GCN_model.py
154
+ networks/GCNwithSolv_model.py
155
+ networks/GC_model.py
156
+ networks/ISATPM_model.py
157
+ networks/ISATPN_model.py
158
+ networks/ISAT_model.py
159
+ networks/MPNN_model.py
160
+ networks/MPNNwithSolv_model.py
161
+ networks/__init__.py
162
+ networks/base.py
163
+ networks/registry.py
164
+ networks/src/AFP.py
165
+ networks/src/BiDropout.py
166
+ networks/src/DMPNN.py
167
+ networks/src/GAT.py
168
+ networks/src/GC.py
169
+ networks/src/GCN.py
170
+ networks/src/ISAT.py
171
+ networks/src/Linear.py
172
+ networks/src/MPNN.py
173
+ networks/src/SolventLayer.py
174
+ networks/src/__init__.py
175
+ networks/src/distGCN.py
176
+ networks/src/pyg_hetero.py
177
+ src/PostProcessor.py
178
+ src/__init__.py
179
+ src/Analyzer/ISAAnalyzer.py
180
+ src/Analyzer/ISAPNAnalyzer.py
181
+ src/Analyzer/ISAwSAnalyzer.py
182
+ src/Analyzer/MolAnalyzer.py
183
+ src/Analyzer/__init__.py
184
+ src/Analyzer/core.py
185
+ src/Analyzer/factory.py
186
+ src/Analyzer/interpretation.py
187
+ src/Analyzer/results.py
188
+ src/DataManager/ISADataManager.py
189
+ src/DataManager/MolDataManager.py
190
+ src/DataManager/__init__.py
191
+ src/DataManager/contracts.py
192
+ src/DataManager/Dataset/GraphDataset.py
193
+ src/DataManager/Dataset/ISAGraphDataset.py
194
+ src/DataManager/Dataset/__init__.py
195
+ src/DataManager/GraphGenerator/ISAGraphGenerator.py
196
+ src/DataManager/GraphGenerator/MolGraphGenerator.py
197
+ src/DataManager/GraphGenerator/__init__.py
198
+ src/NetworkManager/ISANetworkManager.py
199
+ src/NetworkManager/NetworkManager.py
200
+ src/NetworkManager/__init__.py
201
+ src/TrainManager/ISATrainManager.py
202
+ src/TrainManager/TrainManager.py
203
+ src/TrainManager/__init__.py
204
+ src/TrainManager/callbacks.py
205
+ src/utils/PATH.py
206
+ src/utils/__init__.py
207
+ src/utils/argparser.py
208
+ src/utils/checkpointing.py
209
+ src/utils/config_resolution.py
210
+ src/utils/config_validation.py
211
+ src/utils/csv_validation.py
212
+ src/utils/data_quality.py
213
+ src/utils/featureizer.py
214
+ src/utils/functional_group.csv
215
+ src/utils/graph_cache.py
216
+ src/utils/leaderboard.py
217
+ src/utils/metrics.py
218
+ src/utils/module_loader.py
219
+ src/utils/output.py
220
+ src/utils/reproducibility.py
221
+ src/utils/run_manifest.py
222
+ src/utils/scaler.py
223
+ src/utils/sculptor.py
224
+ src/utils/splitting.py
225
+ src/utils/supportfile_saver.py
226
+ src/utils/tools.py
227
+ src/utils/transfer_learning.py
228
+ tests/test_cli_packaging.py
229
+ tests/test_config_validation.py
230
+ tests/test_csv_data_manager_validation.py
231
+ tests/test_csv_validation.py
232
+ tests/test_custom_network.py
233
+ tests/test_data_fixture.py
234
+ tests/test_example_model_compatibility.py
235
+ tests/test_examples_syntax.py
236
+ tests/test_failure_behavior.py
237
+ tests/test_failure_contracts.py
238
+ tests/test_gcn_end_to_end.py
239
+ tests/test_graph_alignment.py
240
+ tests/test_heavy_smoke.py
241
+ tests/test_network_abc.py
242
+ tests/test_network_persistence.py
243
+ tests/test_optimize.py
244
+ tests/test_path_utils.py
245
+ tests/test_public_contracts.py
246
+ tests/test_pyg_data_contract.py
247
+ tests/test_pyg_dmpnn_afp.py
248
+ tests/test_pyg_gcn.py
249
+ tests/test_pyg_isa_models.py
250
+ tests/test_pyg_mpnn_gat.py
251
+ tests/test_runtime_environment.py
252
+ tests/test_scaler_alignment.py
253
+ tests/test_state_dict_contract.py
254
+ tests/test_t3_checkpoint_policy.py
255
+ tests/test_t3_data_quality.py
256
+ tests/test_t3_dataset_contract_matrix.py
257
+ tests/test_t3_graph_cache_integrity.py
258
+ tests/test_t3_grid_search.py
259
+ tests/test_t3_leaderboard.py
260
+ tests/test_t3_registry_smoke_matrix.py
261
+ tests/test_t3_reproducibility.py
262
+ tests/test_t3_run_manifest.py
263
+ tests/test_t3_scaffold_split.py
264
+ tests/test_t3_transfer_learning.py
265
+ tests/test_t4_analyzer_core.py
266
+ tests/test_t5_callbacks.py
267
+ tests/test_t5_config_resolution.py
268
+ tests/test_t5_errors_logging.py
269
+ tests/test_t5_import_discovery.py
270
+ tests/test_t5_manager_contracts.py
271
+ tests/test_t5_verbose_output.py
272
+ tests/test_t6_ci_contract.py
273
+ tests/test_t7_cycle_audit.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ d4cmpp2 = D4CMPP2.cli:main