-
Notifications
You must be signed in to change notification settings - Fork 1
Adding TabSyn examples and ensemble attack code #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
80 commits
Select commit
Hold shift + click to select a range
dbf2a1f
WIP pulling the model code in
lotif ba2bbcc
Removing files that were not supposed to be submitted
lotif bdde267
Merge branch 'main' into marcelo/tabsyn
lotif 42fbabe
WIP started testing
lotif 1b63a7d
WIP progressed on testing
lotif 2af4a09
Finished train test
lotif 5eaebb5
Finished load and synthesize test
lotif 492c106
Started fixing mypy errors
lotif 3e86710
Continue fixing mypy errors
lotif bd41b3c
A bunch more mypy errors fixed
lotif cffe8f9
Fixed all errors 🎉
lotif 92a7b7f
Merge branch 'main' into marcelo/tabsyn
lotif cbd05bc
Merge branch 'main' into marcelo/tabsyn
lotif 990e278
Fixing unit tests
lotif 101e167
Skipping integration tests that need models to be retrained
lotif 7db80e3
adding repickled files
51811b7
Uncommenting tests
lotif 498c21c
Adding tabsyn train code
lotif 34686be
Using the DEVICE variable instead of doing the IF again
lotif db18a07
adding device so it runs in the cluster
lotif 72b7351
Adding synthesize script
lotif bf3585f
Actually fixing synthesize
lotif 22d298d
Adding evaluation script
lotif fc01bae
WIP beginning ensemble attack code
lotif c895320
Actually making the training config
lotif 7ba95a2
Small vae save path fix
lotif b4e6007
Adding make challenge dataset
lotif 067e3c9
adding sampling to training
lotif 2dee575
Fixing the scripts and configs
lotif 1cad880
Small code fix
lotif 547b102
Updating file link
lotif c5008ae
Dropping all id columns, not only the main one
lotif 04ea715
last fixes and scripts
lotif bb681cb
Fixing fine tuning and training data
lotif b0ea88b
Adding evaluation scripts
lotif b13acc6
Adding logs
lotif 6ca19b5
Small fixes to evaluation script
lotif 6aa3032
Addressing comments by coderabbit
lotif b00fc81
Merge branch 'main' into marcelo/tabsyn
lotif c75b529
Addressing comments by David
lotif 7aef62a
CR by David
lotif 26d3cf2
Merge branch 'marcelo/tabsyn' into marcelo/tabsyn-ensemble
lotif a31e1eb
Adding readme instructions
lotif d04cc1d
Better comments on is_numerical handling
lotif 4b55ff5
Merge branch 'marcelo/tabsyn' into marcelo/tabsyn-ensemble
lotif 7216f9d
Merge branch 'main' into marcelo/tabsyn
lotif 84b0c32
Merge branch 'marcelo/tabsyn' into marcelo/tabsyn-ensemble
lotif 76c5f83
Merge branch 'main' into marcelo/tabsyn-ensemble
lotif 7664d3f
small fixes
lotif bed857c
Merge branch 'main' into marcelo/tabsyn-ensemble
lotif 7082237
Small fix
lotif 67b1f03
Bump actions/checkout from 6.0.3 to 7.0.0 (#147)
dependabot[bot] ad5f18a
Addressing CR comments by CodeRabbit. Will address the rest of the co…
lotif 20ffe87
Merge branch 'main' into marcelo/tabsyn-ensemble
lotif 31168ed
Fixing David's CR comments
lotif 6f6acf5
Libraries Upgrade et al. (#150)
emersodb c5a44c0
WIP uploading expected data
lotif 3cca1ec
More files to upload
lotif 2e4de7c
messing with the seeds
lotif 3f29f62
Uploading more data
lotif 03ea35f
More assertion files to upload
lotif 16127cf
Uploading assertion data and reverting tests changes + one additional…
lotif 1bbc1b4
Uncommenting assetion I forgot
lotif cab3529
Revert "Uncommenting assetion I forgot"
lotif e57c324
Revert "Uploading assertion data and reverting tests changes + one ad…
lotif 1bece17
Revert "More assertion files to upload"
lotif b841fda
Revert "Uploading more data"
lotif c874920
Revert "messing with the seeds"
lotif 7a95b84
Revert "More files to upload"
lotif 052d443
Revert "WIP uploading expected data"
lotif 2d1bf75
Uploading new assertion data and modifying one test
lotif 6da7c61
Revert "Uploading new assertion data and modifying one test"
lotif 3371f1d
Reapply "WIP uploading expected data"
lotif d60eadb
Reapply "More files to upload"
lotif 250b240
Reapply "messing with the seeds"
lotif f2f3c48
Reapply "Uploading more data"
lotif a326813
Reapply "More assertion files to upload"
lotif 0c12dbd
Reapply "Uploading assertion data and reverting tests changes + one a…
lotif a3068da
Reapply "Uncommenting assetion I forgot"
lotif 86f47da
Updated pillow v12.2.0 -> v12.3.0
lotif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,7 @@ def log_metrics(header: str, results: dict[str, float]) -> None: | |
| """ | ||
| log(INFO, f"\n{header}\n{SEPARATOR}\n") | ||
| for metric_name, metric_value in results.items(): | ||
| log(INFO, rf"Metric: {metric_name}\Score: {metric_value}") | ||
| log(INFO, rf"Metric: {metric_name}\tScore: {metric_value}") | ||
| log(INFO, f"{SEPARATOR}\n") | ||
|
|
||
|
|
||
|
|
@@ -133,7 +133,6 @@ def should_syntheval_preprocess(cfg: DictConfig, for_privacy: bool) -> bool: | |
| [ | ||
| cfg.ks_tv.run, | ||
| cfg.ci_overlap.run, | ||
| cfg.ks_tv.run, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where did this guy go?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is repeated a couple of lines above this one, so it's an useless line. |
||
| cfg.correlation_diff.run, | ||
| cfg.mean_diff.run, | ||
| cfg.f1_score_diff.run, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # TabSyn Single Table Example | ||
|
|
||
| This example will go over training a single-table [TabSyn](https://arxiv.org/abs/2310.09656) | ||
| model and synthesizing data afterwards. | ||
|
|
||
|
|
||
| ## Downloading data | ||
|
|
||
| First, we need the data. Download it from this | ||
| [Google Drive link](https://drive.google.com/file/d/1HTgfgeL5GXc8uAGfeQirJrUynK7vFeyb/view?usp=drive_link), | ||
| extract the files and place them in a `/data` folder in within this folder | ||
| (`examples/tabsyn`). | ||
|
|
||
| > [!NOTE] | ||
| > If you wish to change the data folder, you can do so by editing the `base_data_dir` attribute | ||
| > of the [`config.yaml`](config.yaml) file. | ||
|
|
||
| Here is a description of the files that have been extracted: | ||
| - `trans.csv`: The training data. It consists of information about bank transactions and it | ||
| contains 20,000 data points. | ||
| - `trans_info.json`: Metadata about the `trans.csv` data, with information such as which columns are | ||
| numerical and which are categorical, what is the task type, etc. | ||
|
|
||
|
|
||
| ## Kicking off training | ||
|
|
||
| To kick off training, simply run the command below from the project's root folder: | ||
|
|
||
| ```bash | ||
| python -m examples.tabsyn.train | ||
| ``` | ||
|
|
||
| > [!NOTE] | ||
| > For all the commands in this file, you can specify a custom `config.yaml` file | ||
| > by adding the option `--config-path=/path-to-config`. It should point to the folder | ||
| > where the custom `config.yaml` file is located. | ||
|
|
||
| ## Training results | ||
|
|
||
| The result files will be saved inside a `/results` folder within this folder | ||
| (`examples/tabsyn`). | ||
|
|
||
| > [!NOTE] | ||
| > If you wish to change the save folder, you can do so by editing the `results_dir` attribute | ||
| > of the [`config.yaml`](config.yaml) file. | ||
|
|
||
| In the `/results/trans` folder, there will be a file called `model.pt`, | ||
|
emersodb marked this conversation as resolved.
|
||
| which is a pytorch saved model. | ||
|
|
||
|
|
||
| ## Synthesizing data | ||
|
|
||
| To synthesize some data with the trained model, run: | ||
|
|
||
| ```bash | ||
| python -m examples.tabsyn.synthesize | ||
| ``` | ||
|
|
||
| If there is already a trained model in the `/results` folder, it will use that model. | ||
| Otherwise it will train one from scratch. At the end of the script, it will save the | ||
| synthesized data to `/results/trans/synthetic_data/trans_synthetic.csv`. | ||
|
lotif marked this conversation as resolved.
|
||
|
|
||
|
|
||
| ## Evaluating the quality of the synthetic data | ||
|
|
||
| ### Alpha Precision | ||
|
|
||
| To run a round of evaluation with [Alpha Precision](https://arxiv.org/abs/2301.07573) | ||
| metrics on a set of synthetic data, run the `evaluate.py` script: | ||
|
|
||
| ```bash | ||
| python -m midst_toolkit.evaluation.quality.scripts.midst_alpha_precision_eval \ | ||
| --synthetic_data_path examples/tabsyn/results/trans/synthetic_data/trans_synthetic.csv \ | ||
| --real_data examples/tabsyn/data/trans_sampled.csv \ | ||
| --meta_info_path examples/tabsyn/data/meta_info.json \ | ||
| --save_directory examples/tabsyn/results/ | ||
| ``` | ||
|
lotif marked this conversation as resolved.
|
||
|
|
||
| It will save the evaluation results under the `/results/model.txt` file. | ||
|
|
||
| ### Additional Metrics | ||
|
|
||
| The calculation of additional metrics are set up in the `evaluate.py` file. They are the | ||
| Kolmogorov-Smirnov (KS) test, Total Variation Distance (TVD), Correlation Matrix Difference | ||
| and Mutual Information Difference. | ||
|
|
||
| To compute those metrics, you can run the command below. The data files should | ||
| be under `/data/{table_name}.csv` for the real data, `/data/{table_name}_sampled.csv` | ||
| for the sampled data used for training, and `/results/{table_name}_synthetic.csv` | ||
| for the synthetic data. | ||
|
lotif marked this conversation as resolved.
|
||
|
|
||
| ```bash | ||
| python -m examples.tabsyn.evaluate | ||
| ``` | ||
|
|
||
| The results will be saved in the `/results/evaluation.json` file. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.