tabdat-synth 0.1.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.
- tabdat_synth-0.1.0/LICENSE +159 -0
- tabdat_synth-0.1.0/PKG-INFO +172 -0
- tabdat_synth-0.1.0/README.md +142 -0
- tabdat_synth-0.1.0/pyproject.toml +66 -0
- tabdat_synth-0.1.0/setup.cfg +4 -0
- tabdat_synth-0.1.0/src/tabdat_synth/__init__.py +67 -0
- tabdat_synth-0.1.0/src/tabdat_synth/core/__init__.py +1 -0
- tabdat_synth-0.1.0/src/tabdat_synth/core/evaluation.py +269 -0
- tabdat_synth-0.1.0/src/tabdat_synth/core/probability.py +21 -0
- tabdat_synth-0.1.0/src/tabdat_synth/core/sampling.py +268 -0
- tabdat_synth-0.1.0/src/tabdat_synth/core/statistics.py +91 -0
- tabdat_synth-0.1.0/src/tabdat_synth/core/validation.py +418 -0
- tabdat_synth-0.1.0/src/tabdat_synth/domain/__init__.py +37 -0
- tabdat_synth-0.1.0/src/tabdat_synth/domain/contracts.py +201 -0
- tabdat_synth-0.1.0/src/tabdat_synth/interfaces/__init__.py +35 -0
- tabdat_synth-0.1.0/src/tabdat_synth/interfaces/bundles.py +425 -0
- tabdat_synth-0.1.0/src/tabdat_synth/interfaces/io.py +438 -0
- tabdat_synth-0.1.0/src/tabdat_synth/interfaces/models.py +163 -0
- tabdat_synth-0.1.0/src/tabdat_synth/interfaces/reports.py +67 -0
- tabdat_synth-0.1.0/src/tabdat_synth/version.py +3 -0
- tabdat_synth-0.1.0/src/tabdat_synth/workflows/__init__.py +19 -0
- tabdat_synth-0.1.0/src/tabdat_synth/workflows/evaluation.py +334 -0
- tabdat_synth-0.1.0/src/tabdat_synth/workflows/pipelines.py +367 -0
- tabdat_synth-0.1.0/src/tabdat_synth.egg-info/PKG-INFO +172 -0
- tabdat_synth-0.1.0/src/tabdat_synth.egg-info/SOURCES.txt +26 -0
- tabdat_synth-0.1.0/src/tabdat_synth.egg-info/dependency_links.txt +1 -0
- tabdat_synth-0.1.0/src/tabdat_synth.egg-info/requires.txt +11 -0
- tabdat_synth-0.1.0/src/tabdat_synth.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work.
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
41
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
42
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
45
|
+
version of the Work and any modifications or additions to that Work or
|
|
46
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
47
|
+
inclusion in the Work by the copyright owner or by an individual or Legal Entity
|
|
48
|
+
authorized to submit on behalf of the copyright owner. For the purposes of this
|
|
49
|
+
definition, "submitted" means any form of electronic, verbal, or written
|
|
50
|
+
communication sent to the Licensor or its representatives, including but not
|
|
51
|
+
limited to communication on electronic mailing lists, source code control
|
|
52
|
+
systems, and issue tracking systems that are managed by, or on behalf of, the
|
|
53
|
+
Licensor for the purpose of discussing and improving the Work, but excluding
|
|
54
|
+
communication that is conspicuously marked or otherwise designated in writing
|
|
55
|
+
by the copyright owner as "Not a Contribution."
|
|
56
|
+
|
|
57
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
58
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
59
|
+
incorporated within the Work.
|
|
60
|
+
|
|
61
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
62
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
63
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
64
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
65
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
66
|
+
Object form.
|
|
67
|
+
|
|
68
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
69
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
70
|
+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
|
71
|
+
section) patent license to make, have made, use, offer to sell, sell, import,
|
|
72
|
+
and otherwise transfer the Work, where such license applies only to those
|
|
73
|
+
patent claims licensable by such Contributor that are necessarily infringed by
|
|
74
|
+
their Contribution(s) alone or by combination of their Contribution(s) with the
|
|
75
|
+
Work to which such Contribution(s) was submitted. If You institute patent
|
|
76
|
+
litigation against any entity (including a cross-claim or counterclaim in a
|
|
77
|
+
lawsuit) alleging that the Work or a Contribution incorporated within the Work
|
|
78
|
+
constitutes direct or contributory patent infringement, then any patent
|
|
79
|
+
licenses granted to You under this License for that Work shall terminate as of
|
|
80
|
+
the date such litigation is filed.
|
|
81
|
+
|
|
82
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
83
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
84
|
+
Source or Object form, provided that You meet the following conditions:
|
|
85
|
+
|
|
86
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy
|
|
87
|
+
of this License; and
|
|
88
|
+
|
|
89
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
90
|
+
You changed the files; and
|
|
91
|
+
|
|
92
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
93
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
94
|
+
Source form of the Work, excluding those notices that do not pertain to any
|
|
95
|
+
part of the Derivative Works; and
|
|
96
|
+
|
|
97
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
98
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
99
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
100
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
101
|
+
following places: within a NOTICE text file distributed as part of the
|
|
102
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
103
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
104
|
+
Works, if and wherever such third-party notices normally appear. The contents
|
|
105
|
+
of the NOTICE file are for informational purposes only and do not modify the
|
|
106
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
107
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
108
|
+
provided that such additional attribution notices cannot be construed as
|
|
109
|
+
modifying the License.
|
|
110
|
+
|
|
111
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
112
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
113
|
+
distribution of Your modifications, or for any such Derivative Works as a
|
|
114
|
+
whole, provided Your use, reproduction, and distribution of the Work otherwise
|
|
115
|
+
complies with the conditions stated in this License.
|
|
116
|
+
|
|
117
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
118
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
119
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
120
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
121
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
122
|
+
executed with Licensor regarding such Contributions.
|
|
123
|
+
|
|
124
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
125
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
126
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
127
|
+
reproducing the content of the NOTICE file.
|
|
128
|
+
|
|
129
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
130
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
131
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
132
|
+
KIND, either express or implied, including, without limitation, any warranties
|
|
133
|
+
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
134
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
135
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
136
|
+
associated with Your exercise of permissions under this License.
|
|
137
|
+
|
|
138
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
139
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
140
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
141
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
142
|
+
direct, indirect, special, incidental, or consequential damages of any character
|
|
143
|
+
arising as a result of this License or out of the use or inability to use the
|
|
144
|
+
Work (including but not limited to damages for loss of goodwill, work stoppage,
|
|
145
|
+
computer failure or malfunction, or any and all other commercial damages or
|
|
146
|
+
losses), even if such Contributor has been advised of the possibility of such
|
|
147
|
+
damages.
|
|
148
|
+
|
|
149
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
150
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
151
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
152
|
+
and/or rights consistent with this License. However, in accepting such
|
|
153
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
154
|
+
responsibility, not on behalf of any other Contributor, and only if You agree
|
|
155
|
+
to indemnify, defend, and hold each Contributor harmless for any liability
|
|
156
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
157
|
+
accepting any such warranty or additional liability.
|
|
158
|
+
|
|
159
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tabdat-synth
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Spec-driven tabular data synthesis with reusable fitted bundles.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/SaehwanPark/tabdat-synth
|
|
7
|
+
Project-URL: Repository, https://github.com/SaehwanPark/tabdat-synth
|
|
8
|
+
Project-URL: Documentation, https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/user-manual.md
|
|
9
|
+
Keywords: synthetic-data,tabular-data,data-generation,research
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: lightgbm>=4.6.0
|
|
20
|
+
Requires-Dist: numpy>=2.2.0
|
|
21
|
+
Requires-Dist: pandas>=2.3.0
|
|
22
|
+
Requires-Dist: polars>=1.40.1
|
|
23
|
+
Requires-Dist: PyYAML>=6.0.2
|
|
24
|
+
Requires-Dist: pyarrow>=18.0.0
|
|
25
|
+
Requires-Dist: scikit-learn>=1.6.0
|
|
26
|
+
Requires-Dist: scipy>=1.15.0
|
|
27
|
+
Provides-Extra: env
|
|
28
|
+
Requires-Dist: python-dotenv>=1.2.2; extra == "env"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# TabDat-Synth
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
TabDat-Synth is a Python package for spec-driven synthetic tabular data generation. It is intended for research, education, benchmarking, and data-science prototyping where real tabular data is sensitive, unavailable, or inconvenient to share.
|
|
36
|
+
|
|
37
|
+
The package learns reusable synthesis artifacts from a source table, then generates new rows from an explicit directed acyclic graph (DAG) specification. It supports empirical sampling, conditioned categorical models, numeric summaries, coefficient-based outcomes, fitted bundle reuse, and evaluation reports.
|
|
38
|
+
|
|
39
|
+
## Motivation
|
|
40
|
+
|
|
41
|
+
Real tabular data often carries privacy, governance, licensing, or access constraints. These constraints can slow method development, teaching, and reproducible examples. TabDat-Synth provides a small, inspectable synthesis engine that can generate plausible tabular datasets while keeping assumptions visible in configuration.
|
|
42
|
+
|
|
43
|
+
## Intended users
|
|
44
|
+
|
|
45
|
+
| User group | Typical use | Relevant docs |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| Research scientists | Simulate data for methods work, sensitivity analyses, and reproducible studies. | [Use cases](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/use-cases.md), [concepts](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/concepts.md) |
|
|
48
|
+
| Data scientists and ML engineers | Prototype pipelines, benchmark models, and create shareable fixtures. | [Getting started](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/getting-started.md), [user manual](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/user-manual.md) |
|
|
49
|
+
| Privacy and governance reviewers | Inspect whether generated data is too close to source records. | [Evaluation metrics](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/evaluation-metrics.md), [concepts](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/concepts.md) |
|
|
50
|
+
| Educators and students | Build realistic classroom or workshop datasets without distributing restricted data. | [Getting started](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/getting-started.md), [examples](https://github.com/SaehwanPark/tabdat-synth/tree/main/docs/examples) |
|
|
51
|
+
| Healthcare data collaborators | Work with public-style examples inspired by claims-data workflows. | [Data-file notes](https://github.com/SaehwanPark/tabdat-synth/tree/main/docs/datafiles-related) |
|
|
52
|
+
|
|
53
|
+
## Features
|
|
54
|
+
|
|
55
|
+
- Spec-driven generation from YAML configuration.
|
|
56
|
+
- Directed synthesis workflows with stable topological execution.
|
|
57
|
+
- Empirical, truncated-normal, categorical-model, coefficient-sum, sigmoid-probability, and Bernoulli-response steps.
|
|
58
|
+
- Built-in categorical backends for LightGBM and logistic regression.
|
|
59
|
+
- Reusable fitted bundles for generating later without the original source file.
|
|
60
|
+
- Evaluation reports for marginal quality and row-level disclosure-risk heuristics.
|
|
61
|
+
- Small public API designed for programmatic Python workflows.
|
|
62
|
+
|
|
63
|
+
## How it works
|
|
64
|
+
|
|
65
|
+
A synthesis run has five stages:
|
|
66
|
+
|
|
67
|
+
1. Load a generation specification and source table.
|
|
68
|
+
2. Prepare source columns according to the declared schema.
|
|
69
|
+
3. Fit step-level artifacts in DAG order.
|
|
70
|
+
4. Sample synthetic rows from the fitted artifacts.
|
|
71
|
+
5. Evaluate the synthetic table against source data when appropriate.
|
|
72
|
+
|
|
73
|
+
The DAG controls which generated columns are available to later steps. For categorical-model steps, declared parents define graph edges, and the fitted model receives the full incoming ancestor context in stable order.
|
|
74
|
+
|
|
75
|
+
## Installation
|
|
76
|
+
|
|
77
|
+
TabDat-Synth requires Python 3.12 or newer and is distributed on PyPI.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
uv add tabdat-synth
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
For one-off installation into an active environment:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
uv pip install tabdat-synth
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For workflows that load local `.env` files through package helpers:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
uv add "tabdat-synth[env]"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Because the package is alpha software, pin downstream projects to an exact release version when reproducibility matters.
|
|
96
|
+
|
|
97
|
+
## Quick start
|
|
98
|
+
|
|
99
|
+
Run the coefficient-based example from the repository root:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from tabdat_synth import generate_from_spec, load_generation_spec
|
|
103
|
+
|
|
104
|
+
spec = load_generation_spec("docs/examples/tiny_coefficient_outcomes.yaml")
|
|
105
|
+
df = generate_from_spec(spec)
|
|
106
|
+
|
|
107
|
+
print(df.shape)
|
|
108
|
+
print(df.head())
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Fit once, save a reusable bundle, and generate later:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from tabdat_synth import (
|
|
115
|
+
fit_synthesizer,
|
|
116
|
+
generate_from_fitted,
|
|
117
|
+
load_fitted_synthesizer,
|
|
118
|
+
load_generation_spec,
|
|
119
|
+
save_fitted_synthesizer,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
spec = load_generation_spec("docs/examples/de_synpuf_beneficiary_phase3.yaml")
|
|
123
|
+
fitted = fit_synthesizer(spec)
|
|
124
|
+
save_fitted_synthesizer(fitted, "tmp/de_synpuf_bundle")
|
|
125
|
+
|
|
126
|
+
reloaded = load_fitted_synthesizer("tmp/de_synpuf_bundle")
|
|
127
|
+
synthetic = generate_from_fitted(reloaded, n_samples=20, random_seed=999)
|
|
128
|
+
print(synthetic.shape)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Documentation
|
|
132
|
+
|
|
133
|
+
- [Getting started](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/getting-started.md): installation, first run, and tests.
|
|
134
|
+
- [Use cases](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/use-cases.md): user groups, workflows, and appropriate boundaries.
|
|
135
|
+
- [Concepts](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/concepts.md): motivation, synthesis mechanism, fitted bundles, and limitations.
|
|
136
|
+
- [User manual](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/user-manual.md): public API, step reference, backend configuration, and bundle details.
|
|
137
|
+
- [Evaluation metrics](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/evaluation-metrics.md): fidelity metrics and disclosure-risk heuristics.
|
|
138
|
+
- [Synthpop comparison](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/synthpop-comparison.md): conceptual relationship to R's `synthpop` package.
|
|
139
|
+
|
|
140
|
+
## Acknowledgement
|
|
141
|
+
|
|
142
|
+
TabDat-Synth is conceptually inspired by R's `synthpop` package and the broader statistical tradition of synthetic data generation.
|
|
143
|
+
|
|
144
|
+
> Nowok, B., Raab, G. M., & Dibben, C. (2016). synthpop: Bespoke creation of synthetic data in R. *Journal of statistical software*, 74, 1-26.
|
|
145
|
+
|
|
146
|
+
Note that this project is a cleanroom Python implementation, not built by reverse engineering `synthpop`, nor reuse `synthpop` source code.
|
|
147
|
+
See [docs/synthpop-comparison.md](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/synthpop-comparison.md) for a full comparison.
|
|
148
|
+
|
|
149
|
+
## Public API
|
|
150
|
+
|
|
151
|
+
Common entry points:
|
|
152
|
+
|
|
153
|
+
- `load_generation_spec(path)`
|
|
154
|
+
- `generate_from_spec(spec)`
|
|
155
|
+
- `fit_synthesizer(spec)`
|
|
156
|
+
- `generate_from_fitted(fitted, *, n_samples=None, random_seed=None)`
|
|
157
|
+
- `save_fitted_synthesizer(fitted, path)`
|
|
158
|
+
- `load_fitted_synthesizer(path)`
|
|
159
|
+
- `evaluate_synthetic_data(source_df, synthetic_df, schema, ...)`
|
|
160
|
+
- `evaluate_from_spec(spec, synthetic_df, ...)`
|
|
161
|
+
- `evaluation_report_to_dict(report)`
|
|
162
|
+
- `save_evaluation_report(report, path)`
|
|
163
|
+
|
|
164
|
+
## Testing
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
uv run --group dev pytest tests/unit tests/regression
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# TabDat-Synth
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
TabDat-Synth is a Python package for spec-driven synthetic tabular data generation. It is intended for research, education, benchmarking, and data-science prototyping where real tabular data is sensitive, unavailable, or inconvenient to share.
|
|
6
|
+
|
|
7
|
+
The package learns reusable synthesis artifacts from a source table, then generates new rows from an explicit directed acyclic graph (DAG) specification. It supports empirical sampling, conditioned categorical models, numeric summaries, coefficient-based outcomes, fitted bundle reuse, and evaluation reports.
|
|
8
|
+
|
|
9
|
+
## Motivation
|
|
10
|
+
|
|
11
|
+
Real tabular data often carries privacy, governance, licensing, or access constraints. These constraints can slow method development, teaching, and reproducible examples. TabDat-Synth provides a small, inspectable synthesis engine that can generate plausible tabular datasets while keeping assumptions visible in configuration.
|
|
12
|
+
|
|
13
|
+
## Intended users
|
|
14
|
+
|
|
15
|
+
| User group | Typical use | Relevant docs |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| Research scientists | Simulate data for methods work, sensitivity analyses, and reproducible studies. | [Use cases](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/use-cases.md), [concepts](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/concepts.md) |
|
|
18
|
+
| Data scientists and ML engineers | Prototype pipelines, benchmark models, and create shareable fixtures. | [Getting started](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/getting-started.md), [user manual](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/user-manual.md) |
|
|
19
|
+
| Privacy and governance reviewers | Inspect whether generated data is too close to source records. | [Evaluation metrics](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/evaluation-metrics.md), [concepts](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/concepts.md) |
|
|
20
|
+
| Educators and students | Build realistic classroom or workshop datasets without distributing restricted data. | [Getting started](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/getting-started.md), [examples](https://github.com/SaehwanPark/tabdat-synth/tree/main/docs/examples) |
|
|
21
|
+
| Healthcare data collaborators | Work with public-style examples inspired by claims-data workflows. | [Data-file notes](https://github.com/SaehwanPark/tabdat-synth/tree/main/docs/datafiles-related) |
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- Spec-driven generation from YAML configuration.
|
|
26
|
+
- Directed synthesis workflows with stable topological execution.
|
|
27
|
+
- Empirical, truncated-normal, categorical-model, coefficient-sum, sigmoid-probability, and Bernoulli-response steps.
|
|
28
|
+
- Built-in categorical backends for LightGBM and logistic regression.
|
|
29
|
+
- Reusable fitted bundles for generating later without the original source file.
|
|
30
|
+
- Evaluation reports for marginal quality and row-level disclosure-risk heuristics.
|
|
31
|
+
- Small public API designed for programmatic Python workflows.
|
|
32
|
+
|
|
33
|
+
## How it works
|
|
34
|
+
|
|
35
|
+
A synthesis run has five stages:
|
|
36
|
+
|
|
37
|
+
1. Load a generation specification and source table.
|
|
38
|
+
2. Prepare source columns according to the declared schema.
|
|
39
|
+
3. Fit step-level artifacts in DAG order.
|
|
40
|
+
4. Sample synthetic rows from the fitted artifacts.
|
|
41
|
+
5. Evaluate the synthetic table against source data when appropriate.
|
|
42
|
+
|
|
43
|
+
The DAG controls which generated columns are available to later steps. For categorical-model steps, declared parents define graph edges, and the fitted model receives the full incoming ancestor context in stable order.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
TabDat-Synth requires Python 3.12 or newer and is distributed on PyPI.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
uv add tabdat-synth
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For one-off installation into an active environment:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv pip install tabdat-synth
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
For workflows that load local `.env` files through package helpers:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
uv add "tabdat-synth[env]"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Because the package is alpha software, pin downstream projects to an exact release version when reproducibility matters.
|
|
66
|
+
|
|
67
|
+
## Quick start
|
|
68
|
+
|
|
69
|
+
Run the coefficient-based example from the repository root:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from tabdat_synth import generate_from_spec, load_generation_spec
|
|
73
|
+
|
|
74
|
+
spec = load_generation_spec("docs/examples/tiny_coefficient_outcomes.yaml")
|
|
75
|
+
df = generate_from_spec(spec)
|
|
76
|
+
|
|
77
|
+
print(df.shape)
|
|
78
|
+
print(df.head())
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Fit once, save a reusable bundle, and generate later:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from tabdat_synth import (
|
|
85
|
+
fit_synthesizer,
|
|
86
|
+
generate_from_fitted,
|
|
87
|
+
load_fitted_synthesizer,
|
|
88
|
+
load_generation_spec,
|
|
89
|
+
save_fitted_synthesizer,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
spec = load_generation_spec("docs/examples/de_synpuf_beneficiary_phase3.yaml")
|
|
93
|
+
fitted = fit_synthesizer(spec)
|
|
94
|
+
save_fitted_synthesizer(fitted, "tmp/de_synpuf_bundle")
|
|
95
|
+
|
|
96
|
+
reloaded = load_fitted_synthesizer("tmp/de_synpuf_bundle")
|
|
97
|
+
synthetic = generate_from_fitted(reloaded, n_samples=20, random_seed=999)
|
|
98
|
+
print(synthetic.shape)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Documentation
|
|
102
|
+
|
|
103
|
+
- [Getting started](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/getting-started.md): installation, first run, and tests.
|
|
104
|
+
- [Use cases](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/use-cases.md): user groups, workflows, and appropriate boundaries.
|
|
105
|
+
- [Concepts](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/concepts.md): motivation, synthesis mechanism, fitted bundles, and limitations.
|
|
106
|
+
- [User manual](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/user-manual.md): public API, step reference, backend configuration, and bundle details.
|
|
107
|
+
- [Evaluation metrics](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/evaluation-metrics.md): fidelity metrics and disclosure-risk heuristics.
|
|
108
|
+
- [Synthpop comparison](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/synthpop-comparison.md): conceptual relationship to R's `synthpop` package.
|
|
109
|
+
|
|
110
|
+
## Acknowledgement
|
|
111
|
+
|
|
112
|
+
TabDat-Synth is conceptually inspired by R's `synthpop` package and the broader statistical tradition of synthetic data generation.
|
|
113
|
+
|
|
114
|
+
> Nowok, B., Raab, G. M., & Dibben, C. (2016). synthpop: Bespoke creation of synthetic data in R. *Journal of statistical software*, 74, 1-26.
|
|
115
|
+
|
|
116
|
+
Note that this project is a cleanroom Python implementation, not built by reverse engineering `synthpop`, nor reuse `synthpop` source code.
|
|
117
|
+
See [docs/synthpop-comparison.md](https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/synthpop-comparison.md) for a full comparison.
|
|
118
|
+
|
|
119
|
+
## Public API
|
|
120
|
+
|
|
121
|
+
Common entry points:
|
|
122
|
+
|
|
123
|
+
- `load_generation_spec(path)`
|
|
124
|
+
- `generate_from_spec(spec)`
|
|
125
|
+
- `fit_synthesizer(spec)`
|
|
126
|
+
- `generate_from_fitted(fitted, *, n_samples=None, random_seed=None)`
|
|
127
|
+
- `save_fitted_synthesizer(fitted, path)`
|
|
128
|
+
- `load_fitted_synthesizer(path)`
|
|
129
|
+
- `evaluate_synthetic_data(source_df, synthetic_df, schema, ...)`
|
|
130
|
+
- `evaluate_from_spec(spec, synthetic_df, ...)`
|
|
131
|
+
- `evaluation_report_to_dict(report)`
|
|
132
|
+
- `save_evaluation_report(report, path)`
|
|
133
|
+
|
|
134
|
+
## Testing
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
uv run --group dev pytest tests/unit tests/regression
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tabdat-synth"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Spec-driven tabular data synthesis with reusable fitted bundles."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
keywords = [
|
|
14
|
+
"synthetic-data",
|
|
15
|
+
"tabular-data",
|
|
16
|
+
"data-generation",
|
|
17
|
+
"research",
|
|
18
|
+
]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Development Status :: 3 - Alpha",
|
|
21
|
+
"Intended Audience :: Science/Research",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Topic :: Scientific/Engineering",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"lightgbm>=4.6.0",
|
|
29
|
+
"numpy>=2.2.0",
|
|
30
|
+
"pandas>=2.3.0",
|
|
31
|
+
"polars>=1.40.1",
|
|
32
|
+
"PyYAML>=6.0.2",
|
|
33
|
+
"pyarrow>=18.0.0",
|
|
34
|
+
"scikit-learn>=1.6.0",
|
|
35
|
+
"scipy>=1.15.0",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.optional-dependencies]
|
|
39
|
+
env = [
|
|
40
|
+
"python-dotenv>=1.2.2",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/SaehwanPark/tabdat-synth"
|
|
45
|
+
Repository = "https://github.com/SaehwanPark/tabdat-synth"
|
|
46
|
+
Documentation = "https://github.com/SaehwanPark/tabdat-synth/blob/main/docs/user-manual.md"
|
|
47
|
+
|
|
48
|
+
[dependency-groups]
|
|
49
|
+
dev = [
|
|
50
|
+
"pytest>=8.3.0",
|
|
51
|
+
"ruff>=0.15.0",
|
|
52
|
+
"twine>=6.2.0",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.packages.find]
|
|
56
|
+
where = ["src"]
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
pythonpath = ["src"]
|
|
60
|
+
markers = [
|
|
61
|
+
"local_data: tests that require private or local data paths and explicit opt-in",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[tool.mypy]
|
|
65
|
+
python_version = "3.12"
|
|
66
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Synthetic data generator package."""
|
|
2
|
+
|
|
3
|
+
from tabdat_synth.version import __version__
|
|
4
|
+
from tabdat_synth.domain.contracts import (
|
|
5
|
+
BernoulliResponseSpec,
|
|
6
|
+
CategoricalModelStepArtifact,
|
|
7
|
+
ColumnSpec,
|
|
8
|
+
CoefficientSumSpec,
|
|
9
|
+
CoefficientTerm,
|
|
10
|
+
ConfiguredStepArtifact,
|
|
11
|
+
EmpiricalStepArtifact,
|
|
12
|
+
DatasetSchema,
|
|
13
|
+
EvaluationReport,
|
|
14
|
+
FittedSynthesizer,
|
|
15
|
+
GenerationSpec,
|
|
16
|
+
GenerationStep,
|
|
17
|
+
MetricResult,
|
|
18
|
+
ModelBackendSpec,
|
|
19
|
+
TruncatedNormalStepArtifact,
|
|
20
|
+
)
|
|
21
|
+
from tabdat_synth.interfaces.bundles import (
|
|
22
|
+
load_fitted_synthesizer,
|
|
23
|
+
save_fitted_synthesizer,
|
|
24
|
+
)
|
|
25
|
+
from tabdat_synth.interfaces.io import load_generation_spec
|
|
26
|
+
from tabdat_synth.interfaces.reports import (
|
|
27
|
+
evaluation_report_to_dict,
|
|
28
|
+
save_evaluation_report,
|
|
29
|
+
)
|
|
30
|
+
from tabdat_synth.workflows.evaluation import (
|
|
31
|
+
evaluate_from_spec,
|
|
32
|
+
evaluate_synthetic_data,
|
|
33
|
+
)
|
|
34
|
+
from tabdat_synth.workflows.pipelines import (
|
|
35
|
+
fit_synthesizer,
|
|
36
|
+
generate_from_fitted,
|
|
37
|
+
generate_from_spec,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
__all__ = [
|
|
41
|
+
"__version__",
|
|
42
|
+
"BernoulliResponseSpec",
|
|
43
|
+
"CategoricalModelStepArtifact",
|
|
44
|
+
"ColumnSpec",
|
|
45
|
+
"CoefficientSumSpec",
|
|
46
|
+
"CoefficientTerm",
|
|
47
|
+
"ConfiguredStepArtifact",
|
|
48
|
+
"DatasetSchema",
|
|
49
|
+
"EmpiricalStepArtifact",
|
|
50
|
+
"EvaluationReport",
|
|
51
|
+
"MetricResult",
|
|
52
|
+
"FittedSynthesizer",
|
|
53
|
+
"GenerationSpec",
|
|
54
|
+
"GenerationStep",
|
|
55
|
+
"ModelBackendSpec",
|
|
56
|
+
"TruncatedNormalStepArtifact",
|
|
57
|
+
"evaluate_from_spec",
|
|
58
|
+
"evaluate_synthetic_data",
|
|
59
|
+
"evaluation_report_to_dict",
|
|
60
|
+
"fit_synthesizer",
|
|
61
|
+
"generate_from_fitted",
|
|
62
|
+
"generate_from_spec",
|
|
63
|
+
"load_fitted_synthesizer",
|
|
64
|
+
"load_generation_spec",
|
|
65
|
+
"save_evaluation_report",
|
|
66
|
+
"save_fitted_synthesizer",
|
|
67
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Pure scientific kernels for synthetic data generation."""
|