synthyverse 0.2.7__tar.gz → 0.2.8__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.
- {synthyverse-0.2.7 → synthyverse-0.2.8}/PKG-INFO +5 -2
- {synthyverse-0.2.7 → synthyverse-0.2.8}/THIRD_PARTY_NOTICES.md +66 -6
- {synthyverse-0.2.7 → synthyverse-0.2.8}/pyproject.toml +6 -2
- synthyverse-0.2.8/synthyverse/benchmark/__init__.py +14 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/benchmark/synthesis.py +149 -71
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/evaluation/__init__.py +2 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/evaluation/eval.py +43 -32
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/evaluation/ml.py +1 -2
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/__init__.py +39 -22
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/_optional.py +13 -1
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/arf_generator/model.py +111 -80
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/base.py +64 -52
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/cdtd_generator/cdtd.py +112 -42
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/cdtd_generator/layers.py +16 -13
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/cdtd_generator/utils.py +1 -5
- synthyverse-0.2.8/synthyverse/generators/config.py +387 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/ctgan_generator/ct_gan.py +89 -17
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/ctgan_generator/synthesizer.py +9 -3
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/dgm_utils.py +34 -15
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/forestdiffusion_generator/fd.py +6 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/forestdiffusion_generator/model.py +22 -1
- synthyverse-0.2.8/synthyverse/generators/tabargn_generator/__init__.py +3 -0
- synthyverse-0.2.8/synthyverse/generators/tabargn_generator/encoding.py +200 -0
- synthyverse-0.2.8/synthyverse/generators/tabargn_generator/model.py +135 -0
- synthyverse-0.2.8/synthyverse/generators/tabargn_generator/tabargn.py +491 -0
- synthyverse-0.2.8/synthyverse/generators/tabbyflow_generator/__init__.py +1 -0
- synthyverse-0.2.8/synthyverse/generators/tabbyflow_generator/flow_model.py +222 -0
- synthyverse-0.2.8/synthyverse/generators/tabbyflow_generator/tabbyflow.py +496 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabcascade_generator/tabcascade.py +138 -51
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabddpm_generator/tabddpm.py +98 -33
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabdiff_generator/tabdiff.py +107 -58
- synthyverse-0.2.8/synthyverse/generators/tabpfn_generator/__init__.py +1 -0
- synthyverse-0.2.8/synthyverse/generators/tabpfn_generator/tabpfn.py +61 -0
- synthyverse-0.2.8/synthyverse/generators/tabpfn_generator/tabpfn_extensions/unsupervised.py +779 -0
- synthyverse-0.2.8/synthyverse/generators/tabpfn_generator/tabpfn_extensions/utils.py +621 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabsyn_generator/tabsyn.py +96 -39
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tvae_generator/synthesizer.py +12 -3
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tvae_generator/tvae.py +94 -17
- synthyverse-0.2.8/synthyverse/generators/utrees_generator/__init__.py +1 -0
- synthyverse-0.2.8/synthyverse/generators/utrees_generator/_utrees/__init__.py +3 -0
- synthyverse-0.2.8/synthyverse/generators/utrees_generator/_utrees/baltobot.py +288 -0
- synthyverse-0.2.8/synthyverse/generators/utrees_generator/_utrees/kdi_quantizer.py +353 -0
- synthyverse-0.2.8/synthyverse/generators/utrees_generator/_utrees/unmasking_trees.py +381 -0
- synthyverse-0.2.8/synthyverse/generators/utrees_generator/kditransform/__init__.py +5 -0
- synthyverse-0.2.8/synthyverse/generators/utrees_generator/kditransform/kdi_discretizer.py +714 -0
- synthyverse-0.2.8/synthyverse/generators/utrees_generator/kditransform/kdi_transformer.py +576 -0
- synthyverse-0.2.8/synthyverse/generators/utrees_generator/kditransform/ksum.py +230 -0
- synthyverse-0.2.8/synthyverse/generators/utrees_generator/utrees.py +71 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/xgbddpm_generator/xgbddpm.py +65 -31
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse.egg-info/PKG-INFO +5 -2
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse.egg-info/SOURCES.txt +22 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse.egg-info/requires.txt +4 -0
- synthyverse-0.2.7/synthyverse/benchmark/__init__.py +0 -9
- {synthyverse-0.2.7 → synthyverse-0.2.8}/LICENSE +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/LICENSES/Apache-2.0.txt +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/LICENSES/CTGAN-BSL-1.1.txt +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/LICENSES/MIT.txt +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/MANIFEST.in +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/NOTICE +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/README.md +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/logo/logo.png +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/setup.cfg +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/evaluation/base.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/evaluation/distances.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/evaluation/fidelity.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/evaluation/preprocessing.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/evaluation/privacy.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/evaluation/utility.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/arf_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/arf_generator/arf.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/arf_generator/utils.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/cdtd_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/ctgan_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/forestdiffusion_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/forestdiffusion_generator/utils/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/forestdiffusion_generator/utils/diffusion.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/forestdiffusion_generator/utils/utils_diffusion.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/forestdiffusion_generator/utils/writer.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/persistence.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/smote_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/smote_generator/smote.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/synthpop_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/synthpop_generator/synthpop.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabcascade_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabcascade_generator/disttree.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabcascade_generator/encoder.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabcascade_generator/highres.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabcascade_generator/lowres.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabddpm_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabddpm_generator/ddpm_utils.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabddpm_generator/gaussian_multinomial_diffsuion.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabddpm_generator/modules.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabdiff_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabdiff_generator/diffusion.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabdiff_generator/modules.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabdiff_generator/noise_schedule.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabdiff_generator/transformer.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabsyn_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabsyn_generator/diffusion.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tabsyn_generator/vae.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/tvae_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/univariate_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/univariate_generator/univariate.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/xgbddpm_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/xgbdiffusion_generator/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/generators/xgbdiffusion_generator/xgbdiffusion.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/utils/__init__.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/utils/reproducibility.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse/utils/utils.py +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse.egg-info/dependency_links.txt +0 -0
- {synthyverse-0.2.7 → synthyverse-0.2.8}/synthyverse.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: synthyverse
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Synthetic data generation and evaluation library
|
|
5
5
|
Author: Jim Achterberg, Saif Ul Islam, Zia Ur Rehman
|
|
6
6
|
License: MIT License
|
|
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
19
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
-
Requires-Python: >=3.
|
|
21
|
+
Requires-Python: >=3.12
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
License-File: LICENSE
|
|
24
24
|
License-File: NOTICE
|
|
@@ -41,8 +41,11 @@ Requires-Dist: torch-ema
|
|
|
41
41
|
Requires-Dist: einops
|
|
42
42
|
Requires-Dist: imbalanced-learn
|
|
43
43
|
Requires-Dist: xgb-diffusion
|
|
44
|
+
Requires-Dist: torchdiffeq>=0.2.5
|
|
44
45
|
Provides-Extra: ctgan
|
|
45
46
|
Requires-Dist: ctgan==0.12.0; extra == "ctgan"
|
|
47
|
+
Provides-Extra: tabpfn
|
|
48
|
+
Requires-Dist: tabpfn>=9.0.0; extra == "tabpfn"
|
|
46
49
|
Provides-Extra: docs
|
|
47
50
|
Requires-Dist: sphinx; extra == "docs"
|
|
48
51
|
Requires-Dist: furo; extra == "docs"
|
|
@@ -16,7 +16,7 @@ The MIT license text for these adapted implementations is kept in
|
|
|
16
16
|
- Upstream license: MIT License
|
|
17
17
|
- Upstream copyright notice: `Copyright (c) 2023 Kristin Blesch, Marvin Wright`
|
|
18
18
|
- Imported or last compared against: `Commit 8b63c1b`
|
|
19
|
-
- Modifications: `Fallback when nodes contain single value.`
|
|
19
|
+
- Modifications: `Fallback when nodes contain single value, and fast vectorized sampling.`
|
|
20
20
|
- Upstream NOTICE text, if any: `None`
|
|
21
21
|
|
|
22
22
|
### CDTDGenerator
|
|
@@ -46,7 +46,7 @@ The MIT license text for these adapted implementations is kept in
|
|
|
46
46
|
- Upstream license: MIT License
|
|
47
47
|
- Upstream copyright notice: `Copyright 2024 Minkai Xu`
|
|
48
48
|
- Imported or last compared against: `Commit 5ecdb33`
|
|
49
|
-
- Modifications: `Refactored API, speed-up masked diffusion by vectorizing loops, fast tensor dataloader.`
|
|
49
|
+
- Modifications: `Refactored API, speed-up masked diffusion by vectorizing loops, fast tensor dataloader, use increasing EMA decay.`
|
|
50
50
|
- Upstream NOTICE text, if any: `None`
|
|
51
51
|
|
|
52
52
|
### TabCascadeGenerator
|
|
@@ -56,7 +56,7 @@ The MIT license text for these adapted implementations is kept in
|
|
|
56
56
|
- Upstream license: MIT License
|
|
57
57
|
- Upstream copyright notice: `Copyright (c) 2026 Markus Mueller`
|
|
58
58
|
- Imported or last compared against: `Commit c8f44bb`
|
|
59
|
-
- Modifications: `Refactored API
|
|
59
|
+
- Modifications: `Refactored API.`
|
|
60
60
|
- Upstream NOTICE text, if any: `None`
|
|
61
61
|
|
|
62
62
|
### ForestDiffusionGenerator
|
|
@@ -69,11 +69,51 @@ The MIT license text for these adapted implementations is kept in
|
|
|
69
69
|
- Modifications: `Refactored API, allow storing XGBoost models in-memory.`
|
|
70
70
|
- Upstream NOTICE text, if any: `None`
|
|
71
71
|
|
|
72
|
+
### TabbyFlowGenerator
|
|
73
|
+
|
|
74
|
+
- Synthyverse files: `synthyverse/generators/tabbyflow_generator/*`
|
|
75
|
+
- Upstream project: `ForestDiffusion-MO (https://github.com/andresguzco/ef-vfm/)`
|
|
76
|
+
- Upstream license: MIT License
|
|
77
|
+
- Upstream copyright notice: `Copyright 2024 Andrés Guzmán-Cordero`
|
|
78
|
+
- Imported or last compared against: `Commit 11fa189`
|
|
79
|
+
- Modifications: `Refactored API, fast tensor dataloader, switch adaptive sampler to euler sampler, remove option to remove NaN outputs, use increasing EMA decay.`
|
|
80
|
+
- Upstream NOTICE text, if any: `None`
|
|
81
|
+
|
|
72
82
|
## Apache-2.0-licensed adapted implementations
|
|
73
83
|
|
|
74
84
|
The Apache-2.0 license text for these adapted implementations is kept in
|
|
75
85
|
`LICENSES/Apache-2.0.txt`.
|
|
76
86
|
|
|
87
|
+
### UTreesGenerator
|
|
88
|
+
|
|
89
|
+
- Synthyverse files: `synthyverse/generators/utrees_generator/*`
|
|
90
|
+
- Upstream project: `utrees (https://github.com/calvinmccarter/unmasking-trees/)`
|
|
91
|
+
- Upstream license: Apache License, Version 2.0
|
|
92
|
+
- Upstream copyright notice: `Copyright 2024 Calvin McCarter`
|
|
93
|
+
- Imported or last compared against: `version 0.3.0`
|
|
94
|
+
- Modifications: `Refactored API, omitting TabPFN functionality.`
|
|
95
|
+
- Upstream NOTICE text, if any: `None`
|
|
96
|
+
|
|
97
|
+
### KDITransform
|
|
98
|
+
|
|
99
|
+
- Synthyverse files: `synthyverse/generators/utrees_generator/kditransform/*`
|
|
100
|
+
- Upstream project: `kditransform (https://github.com/calvinmccarter/kditransform/)`
|
|
101
|
+
- Upstream license: Apache License, Version 2.0
|
|
102
|
+
- Upstream copyright notice: `Copyright 2023-2025 Calvin McCarter`
|
|
103
|
+
- Imported or last compared against: `version 1.1.0`
|
|
104
|
+
- Modifications: `Add support for scikit-learn>=1.6.`
|
|
105
|
+
- Upstream NOTICE text, if any: `None`
|
|
106
|
+
|
|
107
|
+
### TabARGNGenerator
|
|
108
|
+
|
|
109
|
+
- Synthyverse files: `synthyverse/generators/tabargn_generator/*`
|
|
110
|
+
- Upstream project: `mostlyai-engine (https://github.com/mostly-ai/mostlyai-engine)`
|
|
111
|
+
- Upstream license: Apache License, Version 2.0
|
|
112
|
+
- Upstream copyright notice: `Copyright 2025 MOSTLY AI`
|
|
113
|
+
- Imported or last compared against: `version 2.7.0`
|
|
114
|
+
- Modifications: `Refactored API, omitting several optional features from the upstream engine.`
|
|
115
|
+
- Upstream NOTICE text, if any: `None`
|
|
116
|
+
|
|
77
117
|
### TabDDPMGenerator
|
|
78
118
|
|
|
79
119
|
- Synthyverse files: `synthyverse/generators/tabddpm_generator/*`
|
|
@@ -81,7 +121,7 @@ The Apache-2.0 license text for these adapted implementations is kept in
|
|
|
81
121
|
- Upstream license: Apache License, Version 2.0
|
|
82
122
|
- Upstream copyright notice: `Copyright vanderschaarlab 2023`
|
|
83
123
|
- Imported or last compared against: `Commit 23f322f`
|
|
84
|
-
- Modifications: `Refactored API, allow manual specification of categorical features, fast tensor dataloader.`
|
|
124
|
+
- Modifications: `Refactored API, allow manual specification of categorical features, fast tensor dataloader, anneal learning rate by optimizer steps instead of epochs.`
|
|
85
125
|
- Upstream NOTICE text, if any: `None`
|
|
86
126
|
|
|
87
127
|
### TabSynGenerator
|
|
@@ -94,6 +134,26 @@ The Apache-2.0 license text for these adapted implementations is kept in
|
|
|
94
134
|
- Modifications: `Refactor API, fast tensor dataloader.`
|
|
95
135
|
- Upstream NOTICE text, if any: `Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.`
|
|
96
136
|
|
|
137
|
+
### TabPFNGenerator
|
|
138
|
+
|
|
139
|
+
- Synthyverse files: `synthyverse/generators/tabpfn_generator/*`
|
|
140
|
+
- Upstream project: `TabPFN (https://github.com/PriorLabs/TabPFN/)`
|
|
141
|
+
- Upstream license: Apache License, Version 2.0
|
|
142
|
+
- Upstream copyright notice: `Copyright (c) 2026 Prior Labs GmbH`
|
|
143
|
+
- Imported or last compared against: `Commit 15f5e6b`
|
|
144
|
+
- Modifications: `None; wrapped API.`
|
|
145
|
+
- Upstream NOTICE text, if any: `TabPFN. Copyright (c) 2026 Prior Labs GmbH. Third-party attribution notices are provided in THIRD-PARTY-NOTICES.md.`
|
|
146
|
+
|
|
147
|
+
### TabPFN-extensions
|
|
148
|
+
|
|
149
|
+
- Synthyverse files: `synthyverse/generators/tabpfn_generator/tabpfn_extensions/*`
|
|
150
|
+
- Upstream project: `tabpfn-extensions (https://github.com/priorlabs/tabpfn-extensions)`
|
|
151
|
+
- Upstream license: Apache License, Version 2.0
|
|
152
|
+
- Upstream copyright notice: `Copyright (c) 2026 Prior Labs GmbH`
|
|
153
|
+
- Imported or last compared against: `Commit abcafe3`
|
|
154
|
+
- Modifications: `None.`
|
|
155
|
+
- Upstream NOTICE text, if any: `None`
|
|
156
|
+
|
|
97
157
|
### AlphaPrecisionBetaRecall fidelity metric
|
|
98
158
|
|
|
99
159
|
- Synthyverse files: `synthyverse/evaluation/fidelity.py`
|
|
@@ -101,7 +161,7 @@ The Apache-2.0 license text for these adapted implementations is kept in
|
|
|
101
161
|
- Upstream license: Apache License, Version 2.0
|
|
102
162
|
- Upstream copyright notice: `Copyright vanderschaarlab 2023`
|
|
103
163
|
- Imported or last compared against: `Commit 23f322f`
|
|
104
|
-
- Modifications: `Refactored API, allow manual specification k in Beta-Recall.`
|
|
164
|
+
- Modifications: `Refactored API, allow manual specification k in Beta-Recall, and use Gower distance.`
|
|
105
165
|
- Upstream NOTICE text, if any: `None`
|
|
106
166
|
|
|
107
167
|
|
|
@@ -118,7 +178,7 @@ not under the synthyverse MIT License.
|
|
|
118
178
|
- Upstream copyright notice: `The Licensed Work is (c) DataCebo, Inc.; license text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.`
|
|
119
179
|
- License text: `LICENSES/CTGAN-BSL-1.1.txt`
|
|
120
180
|
- Imported or last compared against: `version 0.12.0`
|
|
121
|
-
- Modifications: `
|
|
181
|
+
- Modifications: `enable time-based early stopping, and validation every k steps/epochs.`
|
|
122
182
|
- Upstream NOTICE text, if any: `The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.`
|
|
123
183
|
|
|
124
184
|
## Non-vendored dependencies
|
|
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "synthyverse"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.8"
|
|
8
8
|
description = "Synthetic data generation and evaluation library"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
11
|
license = {text = "MIT License"}
|
|
12
12
|
authors = [
|
|
13
13
|
{name = "Jim Achterberg"},
|
|
@@ -44,6 +44,7 @@ dependencies = [
|
|
|
44
44
|
"einops",
|
|
45
45
|
"imbalanced-learn",
|
|
46
46
|
"xgb-diffusion",
|
|
47
|
+
"torchdiffeq>=0.2.5",
|
|
47
48
|
]
|
|
48
49
|
|
|
49
50
|
[tool.setuptools]
|
|
@@ -63,6 +64,9 @@ Documentation = "https://synthyverse.readthedocs.io"
|
|
|
63
64
|
ctgan = [
|
|
64
65
|
"ctgan==0.12.0",
|
|
65
66
|
]
|
|
67
|
+
tabpfn = [
|
|
68
|
+
"tabpfn>=9.0.0",
|
|
69
|
+
]
|
|
66
70
|
docs = [
|
|
67
71
|
"sphinx",
|
|
68
72
|
"furo",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from importlib import import_module
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def __getattr__(name: str):
|
|
5
|
+
if name in globals():
|
|
6
|
+
return globals()[name]
|
|
7
|
+
if name == "TabularSynthesisBenchmark":
|
|
8
|
+
benchmark = import_module(".synthesis", __name__).TabularSynthesisBenchmark
|
|
9
|
+
globals()[name] = benchmark
|
|
10
|
+
return benchmark
|
|
11
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
__all__ = ["TabularSynthesisBenchmark"]
|
|
@@ -13,10 +13,10 @@ from typing import Any, Dict, Iterable, Optional, Union
|
|
|
13
13
|
import pandas as pd
|
|
14
14
|
from sklearn.model_selection import train_test_split
|
|
15
15
|
|
|
16
|
+
from synthyverse import evaluation
|
|
16
17
|
from synthyverse.generators import DataProcessor, get_generator
|
|
17
18
|
from synthyverse.utils.utils import memory_guarded
|
|
18
19
|
|
|
19
|
-
|
|
20
20
|
RESULT_COLUMNS = ["metric name", "metric value", "train_seed", "set"]
|
|
21
21
|
BYTES_PER_MIB = 1024 * 1024
|
|
22
22
|
_PROCESS_MEMORY_READER = None
|
|
@@ -36,10 +36,9 @@ class TabularSynthesisBenchmark:
|
|
|
36
36
|
* call ``train()`` and ``eval()`` separately to reuse saved models or run
|
|
37
37
|
different metrics later.
|
|
38
38
|
|
|
39
|
-
When ``model_save_dir`` is provided, the benchmark
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
``pandas.DataFrame`` and can also be written to CSV.
|
|
39
|
+
When ``model_save_dir`` is provided, the benchmark caches fitted processors
|
|
40
|
+
there and saves trained generators when ``save_models=True``. Results are
|
|
41
|
+
returned as a long-format ``pandas.DataFrame`` and can also be written to CSV.
|
|
43
42
|
|
|
44
43
|
Args:
|
|
45
44
|
X (pd.DataFrame): Real tabular dataset to benchmark on.
|
|
@@ -52,10 +51,11 @@ class TabularSynthesisBenchmark:
|
|
|
52
51
|
target_column (str or None): Column used for supervised metrics and,
|
|
53
52
|
when categorical, stratified splits. Use ``None`` when there is no
|
|
54
53
|
target column.
|
|
55
|
-
model_save_dir (str or Path or None): Directory used for
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
model_save_dir (str or Path or None): Directory used for cached processors
|
|
55
|
+
under ``model_save_dir/processors`` and optional saved models under
|
|
56
|
+
``model_save_dir/models``. When ``None``, neither is saved.
|
|
57
|
+
Use a separate directory
|
|
58
|
+
for each dataset and split/preprocessing configuration. Default: None.
|
|
59
59
|
random_state (int): First seed used for train splits and synthetic set
|
|
60
60
|
sampling. Additional train seeds are consecutive integers starting
|
|
61
61
|
from this value. Default: 42.
|
|
@@ -67,6 +67,8 @@ class TabularSynthesisBenchmark:
|
|
|
67
67
|
``"missforest"``. Default: ``"drop"``.
|
|
68
68
|
monitor_memory (bool): Whether to record peak CPU and, when available,
|
|
69
69
|
CUDA memory used by training. Default: False.
|
|
70
|
+
save_models (bool): Whether to save trained generators when
|
|
71
|
+
``model_save_dir`` is set. Default: False.
|
|
70
72
|
reuse_processors (bool): Whether to reuse saved preprocessing artifacts
|
|
71
73
|
for each train seed when available. Default: True.
|
|
72
74
|
max_eval_samples (int or None): Default maximum number of rows per real
|
|
@@ -75,6 +77,9 @@ class TabularSynthesisBenchmark:
|
|
|
75
77
|
the same varying seed used for sampling synthetic data. Each
|
|
76
78
|
synthetic set is generated at the (capped) real-train evaluation
|
|
77
79
|
size. Default: 100_000.
|
|
80
|
+
allow_generated_missings (bool): Whether to evaluate generated samples
|
|
81
|
+
with missing numerical values. When False, skipped sets receive an
|
|
82
|
+
``evaluation_status`` result explaining the skip. Default: False.
|
|
78
83
|
dataset_save_dir (str or Path or None): Directory for saving sampled
|
|
79
84
|
synthetic datasets as parquet files. When provided, datasets are
|
|
80
85
|
saved under ``dataset_save_dir/train_seed/sampling_seed``.
|
|
@@ -93,7 +98,8 @@ class TabularSynthesisBenchmark:
|
|
|
93
98
|
... generator_params={"epochs": 300},
|
|
94
99
|
... categorical_features=["sex", "mortality"],
|
|
95
100
|
... target_column="mortality",
|
|
96
|
-
... model_save_dir="dataset
|
|
101
|
+
... model_save_dir="dataset",
|
|
102
|
+
... save_models=True,
|
|
97
103
|
... random_state=42,
|
|
98
104
|
... )
|
|
99
105
|
>>>
|
|
@@ -109,7 +115,8 @@ class TabularSynthesisBenchmark:
|
|
|
109
115
|
... generator_params={"epochs": 300},
|
|
110
116
|
... categorical_features=["sex", "mortality"],
|
|
111
117
|
... target_column="mortality",
|
|
112
|
-
... model_save_dir="dataset
|
|
118
|
+
... model_save_dir="dataset",
|
|
119
|
+
... save_models=True,
|
|
113
120
|
... random_state=42,
|
|
114
121
|
... )
|
|
115
122
|
>>> benchmark.train(n_train_seeds=3)
|
|
@@ -120,7 +127,8 @@ class TabularSynthesisBenchmark:
|
|
|
120
127
|
... generator_params={"epochs": 300},
|
|
121
128
|
... categorical_features=["sex", "mortality"],
|
|
122
129
|
... target_column="mortality",
|
|
123
|
-
... model_save_dir="dataset
|
|
130
|
+
... model_save_dir="dataset",
|
|
131
|
+
... save_models=True,
|
|
124
132
|
... random_state=42,
|
|
125
133
|
... )
|
|
126
134
|
>>> results = reloaded_benchmark.eval(
|
|
@@ -141,8 +149,10 @@ class TabularSynthesisBenchmark:
|
|
|
141
149
|
constraints: Optional[Union[list[str], str]] = None,
|
|
142
150
|
missing_imputation_method: str = "drop",
|
|
143
151
|
monitor_memory: bool = False,
|
|
152
|
+
save_models: bool = False,
|
|
144
153
|
reuse_processors: bool = True,
|
|
145
154
|
max_eval_samples: Optional[int] = 100_000,
|
|
155
|
+
allow_generated_missings: bool = False,
|
|
146
156
|
dataset_save_dir: Optional[Union[str, Path]] = None,
|
|
147
157
|
cap_train_time: Optional[float] = None,
|
|
148
158
|
):
|
|
@@ -157,8 +167,10 @@ class TabularSynthesisBenchmark:
|
|
|
157
167
|
self.constraints = self._normalize_constraints(constraints)
|
|
158
168
|
self.missing_imputation_method = missing_imputation_method
|
|
159
169
|
self.monitor_memory = monitor_memory
|
|
170
|
+
self.save_models = save_models
|
|
160
171
|
self.reuse_processors = reuse_processors
|
|
161
172
|
self.max_eval_samples = self._validate_max_eval_samples(max_eval_samples)
|
|
173
|
+
self.allow_generated_missings = allow_generated_missings
|
|
162
174
|
self.dataset_save_dir = (
|
|
163
175
|
None if dataset_save_dir is None else Path(dataset_save_dir)
|
|
164
176
|
)
|
|
@@ -178,7 +190,8 @@ class TabularSynthesisBenchmark:
|
|
|
178
190
|
For each train seed, this method creates the train/test split, fits or
|
|
179
191
|
loads the corresponding ``DataProcessor``, trains the
|
|
180
192
|
configured generator, and saves the trained generator under
|
|
181
|
-
``model_save_dir/models`` when ``
|
|
193
|
+
``model_save_dir/models`` when ``save_models=True`` and ``model_save_dir``
|
|
194
|
+
is set.
|
|
182
195
|
|
|
183
196
|
Use this method when you want to train models now and evaluate them
|
|
184
197
|
later with ``eval()``. Use the same ``test_size`` during evaluation so
|
|
@@ -236,7 +249,7 @@ class TabularSynthesisBenchmark:
|
|
|
236
249
|
if write_results:
|
|
237
250
|
self._save_results(result_rows, results_path)
|
|
238
251
|
break
|
|
239
|
-
if self.model_save_dir is not None:
|
|
252
|
+
if self.save_models and self.model_save_dir is not None:
|
|
240
253
|
generator.save(self._model_dir(train_seed))
|
|
241
254
|
|
|
242
255
|
rows = [
|
|
@@ -247,11 +260,14 @@ class TabularSynthesisBenchmark:
|
|
|
247
260
|
"set": pd.NA,
|
|
248
261
|
}
|
|
249
262
|
]
|
|
263
|
+
rows.extend(trainable_param_rows(generator, train_seed))
|
|
264
|
+
rows.extend(trained_steps_epoch_rows(generator, train_seed))
|
|
250
265
|
rows.extend(memory_metric_rows("training", memory_monitor, train_seed))
|
|
251
266
|
result_rows.extend(rows)
|
|
252
267
|
new_rows.extend(rows)
|
|
253
268
|
if write_results:
|
|
254
269
|
self._save_results(result_rows, results_path)
|
|
270
|
+
del generator, processor, processed, split
|
|
255
271
|
|
|
256
272
|
return pd.DataFrame(new_rows, columns=RESULT_COLUMNS)
|
|
257
273
|
|
|
@@ -326,7 +342,7 @@ class TabularSynthesisBenchmark:
|
|
|
326
342
|
processor, processed = self._load_or_fit_processor(train_seed, split)
|
|
327
343
|
generator = self._load_generator(generator_cls, train_seed)
|
|
328
344
|
|
|
329
|
-
rows
|
|
345
|
+
for rows in self._evaluate_generator(
|
|
330
346
|
generator=generator,
|
|
331
347
|
processor=processor,
|
|
332
348
|
processed=processed,
|
|
@@ -334,10 +350,11 @@ class TabularSynthesisBenchmark:
|
|
|
334
350
|
n_sets=n_sets,
|
|
335
351
|
train_seed=train_seed,
|
|
336
352
|
max_eval_samples=max_eval_samples,
|
|
337
|
-
)
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
353
|
+
):
|
|
354
|
+
result_rows.extend(rows)
|
|
355
|
+
new_rows.extend(rows)
|
|
356
|
+
self._save_results(result_rows, results_path)
|
|
357
|
+
del generator, processor, processed, split
|
|
341
358
|
|
|
342
359
|
return pd.DataFrame(new_rows, columns=RESULT_COLUMNS)
|
|
343
360
|
|
|
@@ -411,6 +428,8 @@ class TabularSynthesisBenchmark:
|
|
|
411
428
|
result_rows.extend(rows)
|
|
412
429
|
new_rows.extend(rows)
|
|
413
430
|
self._save_results(result_rows, results_path)
|
|
431
|
+
del X_syn, X_train_eval, X_test_eval
|
|
432
|
+
del processor, processed, split
|
|
414
433
|
|
|
415
434
|
return pd.DataFrame(new_rows, columns=RESULT_COLUMNS)
|
|
416
435
|
|
|
@@ -486,7 +505,7 @@ class TabularSynthesisBenchmark:
|
|
|
486
505
|
new_rows.extend(rows)
|
|
487
506
|
self._save_results(result_rows, results_path)
|
|
488
507
|
break
|
|
489
|
-
if self.model_save_dir is not None:
|
|
508
|
+
if self.save_models and self.model_save_dir is not None:
|
|
490
509
|
generator.save(self._model_dir(train_seed))
|
|
491
510
|
|
|
492
511
|
rows = [
|
|
@@ -497,12 +516,14 @@ class TabularSynthesisBenchmark:
|
|
|
497
516
|
"set": pd.NA,
|
|
498
517
|
}
|
|
499
518
|
]
|
|
519
|
+
rows.extend(trainable_param_rows(generator, train_seed))
|
|
520
|
+
rows.extend(trained_steps_epoch_rows(generator, train_seed))
|
|
500
521
|
rows.extend(memory_metric_rows("training", memory_monitor, train_seed))
|
|
501
522
|
result_rows.extend(rows)
|
|
502
523
|
new_rows.extend(rows)
|
|
503
524
|
self._save_results(result_rows, results_path)
|
|
504
525
|
|
|
505
|
-
rows
|
|
526
|
+
for rows in self._evaluate_generator(
|
|
506
527
|
generator=generator,
|
|
507
528
|
processor=processor,
|
|
508
529
|
processed=processed,
|
|
@@ -510,10 +531,11 @@ class TabularSynthesisBenchmark:
|
|
|
510
531
|
n_sets=n_sets,
|
|
511
532
|
train_seed=train_seed,
|
|
512
533
|
max_eval_samples=max_eval_samples,
|
|
513
|
-
)
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
534
|
+
):
|
|
535
|
+
result_rows.extend(rows)
|
|
536
|
+
new_rows.extend(rows)
|
|
537
|
+
self._save_results(result_rows, results_path)
|
|
538
|
+
del generator, processor, processed, split
|
|
517
539
|
|
|
518
540
|
return pd.DataFrame(new_rows, columns=RESULT_COLUMNS)
|
|
519
541
|
|
|
@@ -561,14 +583,10 @@ class TabularSynthesisBenchmark:
|
|
|
561
583
|
processor.save(processor_dir)
|
|
562
584
|
print(f"Saved DataProcessor to {processor_file}")
|
|
563
585
|
|
|
564
|
-
X_train_model = processed
|
|
565
|
-
X_test_model = processor.preprocess(X=split["test"])
|
|
566
|
-
|
|
567
586
|
return processor, {
|
|
568
|
-
"train_model":
|
|
569
|
-
"
|
|
570
|
-
"
|
|
571
|
-
"test_eval": processor.postprocess(X_test_model),
|
|
587
|
+
"train_model": processed,
|
|
588
|
+
"train_eval": processor.imputer.transform(split["train"]),
|
|
589
|
+
"test_eval": processor.imputer.transform(split["test"]),
|
|
572
590
|
}
|
|
573
591
|
|
|
574
592
|
def _fit_generator(
|
|
@@ -642,8 +660,7 @@ class TabularSynthesisBenchmark:
|
|
|
642
660
|
n_sets: int,
|
|
643
661
|
train_seed: int,
|
|
644
662
|
max_eval_samples: Optional[int],
|
|
645
|
-
) -> list[dict[str, Any]]:
|
|
646
|
-
result_rows = []
|
|
663
|
+
) -> Iterable[list[dict[str, Any]]]:
|
|
647
664
|
for set_index in memory_guarded(range(n_sets)):
|
|
648
665
|
sampling_seed = self.random_state + set_index
|
|
649
666
|
X_train_eval = self._subsample_eval_dataset(
|
|
@@ -669,15 +686,15 @@ class TabularSynthesisBenchmark:
|
|
|
669
686
|
X_syn,
|
|
670
687
|
)
|
|
671
688
|
|
|
672
|
-
|
|
689
|
+
rows = [
|
|
673
690
|
{
|
|
674
691
|
"metric name": "sampling_time_seconds",
|
|
675
692
|
"metric value": sampling_time,
|
|
676
693
|
"train_seed": train_seed,
|
|
677
694
|
"set": set_index,
|
|
678
695
|
}
|
|
679
|
-
|
|
680
|
-
|
|
696
|
+
]
|
|
697
|
+
rows.extend(
|
|
681
698
|
self._evaluate_synthetic_datasets(
|
|
682
699
|
X_train_eval=X_train_eval,
|
|
683
700
|
X_test_eval=X_test_eval,
|
|
@@ -688,8 +705,8 @@ class TabularSynthesisBenchmark:
|
|
|
688
705
|
sampling_seed=sampling_seed,
|
|
689
706
|
)
|
|
690
707
|
)
|
|
691
|
-
|
|
692
|
-
|
|
708
|
+
del X_syn, X_train_eval, X_test_eval
|
|
709
|
+
yield rows
|
|
693
710
|
|
|
694
711
|
def _evaluate_synthetic_datasets(
|
|
695
712
|
self,
|
|
@@ -701,12 +718,26 @@ class TabularSynthesisBenchmark:
|
|
|
701
718
|
set_index: int,
|
|
702
719
|
sampling_seed: int,
|
|
703
720
|
) -> list[dict[str, Any]]:
|
|
704
|
-
from synthyverse.evaluation.eval import TabularMetricEvaluator
|
|
705
|
-
|
|
706
721
|
eval_categorical_features = [
|
|
707
722
|
col for col in self.categorical_features if col in X_train_eval.columns
|
|
708
723
|
]
|
|
709
|
-
|
|
724
|
+
numerical_features = [
|
|
725
|
+
col for col in X_syn.columns if col not in eval_categorical_features
|
|
726
|
+
]
|
|
727
|
+
if (
|
|
728
|
+
not self.allow_generated_missings
|
|
729
|
+
and X_syn[numerical_features].isna().any().any()
|
|
730
|
+
):
|
|
731
|
+
return [
|
|
732
|
+
{
|
|
733
|
+
"metric name": "evaluation_status",
|
|
734
|
+
"metric value": "skipped due to generated missing values",
|
|
735
|
+
"train_seed": train_seed,
|
|
736
|
+
"set": set_index,
|
|
737
|
+
}
|
|
738
|
+
]
|
|
739
|
+
|
|
740
|
+
evaluator = evaluation.TabularMetricEvaluator(
|
|
710
741
|
metrics=metrics,
|
|
711
742
|
target_column=self.target_column,
|
|
712
743
|
random_state=sampling_seed,
|
|
@@ -783,8 +814,9 @@ class TabularSynthesisBenchmark:
|
|
|
783
814
|
return generator
|
|
784
815
|
|
|
785
816
|
legacy_name = re.split(r"[\W_]+", generator, maxsplit=1)[0]
|
|
786
|
-
if
|
|
787
|
-
legacy_name
|
|
817
|
+
if (
|
|
818
|
+
legacy_name != generator
|
|
819
|
+
and TabularSynthesisBenchmark._is_registered_generator(legacy_name)
|
|
788
820
|
):
|
|
789
821
|
return legacy_name
|
|
790
822
|
return generator
|
|
@@ -834,9 +866,7 @@ class TabularSynthesisBenchmark:
|
|
|
834
866
|
return self.model_save_dir / "processors" / str(train_seed)
|
|
835
867
|
|
|
836
868
|
def _model_dir(self, train_seed: int) -> Path:
|
|
837
|
-
return (
|
|
838
|
-
self.model_save_dir / "models" / self.generator / f"train_seed_{train_seed}"
|
|
839
|
-
)
|
|
869
|
+
return self.model_save_dir / "models" / self.generator / str(train_seed)
|
|
840
870
|
|
|
841
871
|
def _dataset_dir(self, train_seed: int, sampling_seed: int) -> Path:
|
|
842
872
|
return self.dataset_save_dir / str(train_seed) / str(sampling_seed)
|
|
@@ -872,7 +902,7 @@ class TabularSynthesisBenchmark:
|
|
|
872
902
|
return
|
|
873
903
|
dataset_dir = self._dataset_dir(train_seed, sampling_seed)
|
|
874
904
|
dataset_dir.mkdir(parents=True, exist_ok=True)
|
|
875
|
-
X_syn.to_parquet(dataset_dir / "
|
|
905
|
+
X_syn.to_parquet(dataset_dir / "syn.parquet", index=False)
|
|
876
906
|
|
|
877
907
|
def _load_synthetic_dataset(
|
|
878
908
|
self,
|
|
@@ -881,7 +911,7 @@ class TabularSynthesisBenchmark:
|
|
|
881
911
|
processor: DataProcessor,
|
|
882
912
|
) -> pd.DataFrame:
|
|
883
913
|
dataset_dir = self._dataset_dir(train_seed, sampling_seed)
|
|
884
|
-
train_path = dataset_dir / "
|
|
914
|
+
train_path = dataset_dir / "syn.parquet"
|
|
885
915
|
if not train_path.exists():
|
|
886
916
|
raise FileNotFoundError(
|
|
887
917
|
f"No saved synthetic datasets found for train_seed={train_seed}, "
|
|
@@ -947,34 +977,26 @@ class TabularSynthesisBenchmark:
|
|
|
947
977
|
|
|
948
978
|
|
|
949
979
|
def make_csv_safe(value: Any) -> Any:
|
|
980
|
+
value = _json_safe(value)
|
|
981
|
+
if isinstance(value, (dict, list)):
|
|
982
|
+
return json.dumps(value)
|
|
983
|
+
return pd.NA if value is None else value
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
def _json_safe(value: Any) -> Any:
|
|
950
987
|
if isinstance(value, dict):
|
|
951
|
-
return
|
|
952
|
-
{str(key): make_csv_safe(item) for key, item in value.items()}
|
|
953
|
-
)
|
|
988
|
+
return {str(key): _json_safe(item) for key, item in value.items()}
|
|
954
989
|
if isinstance(value, (list, tuple, set)):
|
|
955
|
-
return
|
|
990
|
+
return [_json_safe(item) for item in value]
|
|
956
991
|
if isinstance(value, Path):
|
|
957
992
|
return str(value)
|
|
958
993
|
if isinstance(value, pd.DataFrame):
|
|
959
|
-
return value.to_json(orient="records")
|
|
960
|
-
if isinstance(value, pd.Series):
|
|
961
|
-
return make_csv_safe(value.to_list())
|
|
994
|
+
return json.loads(value.to_json(orient="records"))
|
|
962
995
|
if hasattr(value, "tolist") and not isinstance(value, (str, bytes)):
|
|
963
|
-
|
|
964
|
-
return make_csv_safe(value.tolist())
|
|
965
|
-
except TypeError:
|
|
966
|
-
pass
|
|
996
|
+
return _json_safe(value.tolist())
|
|
967
997
|
if hasattr(value, "item") and not isinstance(value, (str, bytes)):
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
except (TypeError, ValueError):
|
|
971
|
-
pass
|
|
972
|
-
try:
|
|
973
|
-
if pd.isna(value):
|
|
974
|
-
return pd.NA
|
|
975
|
-
except (TypeError, ValueError):
|
|
976
|
-
pass
|
|
977
|
-
return value
|
|
998
|
+
return _json_safe(value.item())
|
|
999
|
+
return None if pd.isna(value) else value
|
|
978
1000
|
|
|
979
1001
|
|
|
980
1002
|
def flatten_metrics(metrics: Any, prefix: str = "") -> Iterable[tuple[str, Any]]:
|
|
@@ -1068,10 +1090,39 @@ def training_timeout_rows(
|
|
|
1068
1090
|
]
|
|
1069
1091
|
|
|
1070
1092
|
|
|
1093
|
+
def trainable_param_rows(generator, train_seed: int) -> list[dict[str, Any]]:
|
|
1094
|
+
get_trainable_params = getattr(generator, "get_trainable_params", None)
|
|
1095
|
+
if not callable(get_trainable_params):
|
|
1096
|
+
return []
|
|
1097
|
+
return [
|
|
1098
|
+
{
|
|
1099
|
+
"metric name": "trainable_params",
|
|
1100
|
+
"metric value": get_trainable_params(),
|
|
1101
|
+
"train_seed": train_seed,
|
|
1102
|
+
"set": pd.NA,
|
|
1103
|
+
}
|
|
1104
|
+
]
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
def trained_steps_epoch_rows(generator, train_seed: int) -> list[dict[str, Any]]:
|
|
1108
|
+
get_trained_steps_epochs = getattr(generator, "get_trained_steps_epochs", None)
|
|
1109
|
+
if not callable(get_trained_steps_epochs):
|
|
1110
|
+
return []
|
|
1111
|
+
return [
|
|
1112
|
+
{
|
|
1113
|
+
"metric name": name,
|
|
1114
|
+
"metric value": make_csv_safe(value),
|
|
1115
|
+
"train_seed": train_seed,
|
|
1116
|
+
"set": pd.NA,
|
|
1117
|
+
}
|
|
1118
|
+
for name, value in flatten_metrics(get_trained_steps_epochs())
|
|
1119
|
+
]
|
|
1120
|
+
|
|
1121
|
+
|
|
1071
1122
|
class PeakMemoryMonitor:
|
|
1072
1123
|
"""Sample memory used above the pre-training baseline."""
|
|
1073
1124
|
|
|
1074
|
-
def __init__(self, interval_seconds: float = 1
|
|
1125
|
+
def __init__(self, interval_seconds: float = 0.1):
|
|
1075
1126
|
self.interval_seconds = interval_seconds
|
|
1076
1127
|
self.peak_memory_mb: Optional[float] = None
|
|
1077
1128
|
self.peak_cuda_memory_mb: Optional[float] = None
|
|
@@ -1162,7 +1213,34 @@ def _make_psutil_memory_reader():
|
|
|
1162
1213
|
except Exception:
|
|
1163
1214
|
return None
|
|
1164
1215
|
|
|
1216
|
+
def process_memory_bytes(current_process) -> Optional[int]:
|
|
1217
|
+
try:
|
|
1218
|
+
memory_info = current_process.memory_full_info()
|
|
1219
|
+
except Exception:
|
|
1220
|
+
try:
|
|
1221
|
+
return int(current_process.memory_info().rss)
|
|
1222
|
+
except Exception:
|
|
1223
|
+
return None
|
|
1224
|
+
|
|
1225
|
+
for field in ("pss", "uss", "rss"):
|
|
1226
|
+
value = getattr(memory_info, field, None)
|
|
1227
|
+
if value is not None:
|
|
1228
|
+
return int(value)
|
|
1229
|
+
return None
|
|
1230
|
+
|
|
1165
1231
|
def read_memory_bytes() -> Optional[int]:
|
|
1232
|
+
try:
|
|
1233
|
+
processes = [process, *process.children(recursive=True)]
|
|
1234
|
+
except Exception:
|
|
1235
|
+
processes = [process]
|
|
1236
|
+
|
|
1237
|
+
total_bytes = 0
|
|
1238
|
+
for current_process in processes:
|
|
1239
|
+
memory_bytes = process_memory_bytes(current_process)
|
|
1240
|
+
if memory_bytes is not None:
|
|
1241
|
+
total_bytes += memory_bytes
|
|
1242
|
+
if total_bytes:
|
|
1243
|
+
return total_bytes
|
|
1166
1244
|
try:
|
|
1167
1245
|
return int(process.memory_info().rss)
|
|
1168
1246
|
except Exception:
|
|
@@ -24,6 +24,8 @@ _METRIC_BY_NAME = {name: cls for cls, (_, name) in _METRICS.items()}
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def __getattr__(name: str):
|
|
27
|
+
if name in globals():
|
|
28
|
+
return globals()[name]
|
|
27
29
|
if name == "BaseMetric":
|
|
28
30
|
base = import_module(".base", __name__).BaseMetric
|
|
29
31
|
globals()[name] = base
|