Resume SynthData0523 main/c6 batch 4
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+34
- SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/public/test.csvAdded+3
- SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/public/train.csvAdded+3
- SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/public/val.csvAdded+3
- SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/realtabformer/adapter_report.jsonAdded+7
- SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/realtabformer/adapter_transforms_applied.jsonAdded+1
- SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/realtabformer/model_input_manifest.jsonAdded+176
- SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/train_20260329_231510.logAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/_tabbyflow_gen.pyAdded+33
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/_tabbyflow_train.pyAdded+22
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/input_snapshot.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/models_tabbyflow/trained.ptAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/public_gate/normalized_schema_snapshot.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/public_gate/public_gate_report.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/public_gate/staged_input_manifest.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/runtime_result.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/staged_features.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/test.csvAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/train.csvAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/val.csvAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/tabbyflow/adapter_report.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/tabbyflow/adapter_transforms_applied.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/tabbyflow/model_input_manifest.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabbyflow-c6-7636-20260420_063635.csvAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabbyflow_train_meta.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_cat_test.npyAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_cat_train.npyAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_cat_val.npyAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_num_test.npyAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_num_train.npyAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_num_val.npyAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/info.jsonAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/real.csvAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/test.csvAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/val.csvAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/y_test.npyAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/y_train.npyAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/y_val.npyAdded+3
- SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/train_20260420_063042.logAdded+3
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/._dataAdded
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/.gitignoreAdded+22
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/.gitmodulesAdded+9
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CONFIG_DESCRIPTION.mdAdded+78
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/.gitignoreAdded+1
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/README.mdAdded+49
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/columns.jsonAdded+3
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/model copy/ctabgan.pyAdded+70
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/model copy/eval/evaluation.pyAdded+193
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/model copy/pipeline/data_preparation.pyAdded+130
- SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/model copy/privacy_utils/rdp_accountant.pyAdded+280
4739 unmodified lines4740474147424739 unmodified linesSynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/rtf_checkpoints/checkpoint-23900/scaler.pt filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/rtf_checkpoints/checkpoint-23900/scheduler.pt filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/rtf_checkpoints/checkpoint-23900/training_args.bin filter=lfs diff=lfs merge=lfs -text4739 unmodified lines47404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764739 unmodified linesSynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/rtf_checkpoints/checkpoint-23900/scaler.pt filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/rtf_checkpoints/checkpoint-23900/scheduler.pt filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/rtf_checkpoints/checkpoint-23900/training_args.bin filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/public/test.csv filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/public/train.csv filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/public/val.csv filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/train_20260329_231510.log filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/input_snapshot.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/models_tabbyflow/trained.pt filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/public_gate/normalized_schema_snapshot.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/public_gate/public_gate_report.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/public_gate/staged_input_manifest.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/runtime_result.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/staged_features.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/test.csv filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/train.csv filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/val.csv filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/tabbyflow/adapter_report.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/tabbyflow/adapter_transforms_applied.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/tabbyflow/model_input_manifest.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabbyflow-c6-7636-20260420_063635.csv filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabbyflow_train_meta.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_cat_test.npy filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_cat_train.npy filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_cat_val.npy filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_num_test.npy filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_num_train.npy filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_num_val.npy filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/info.json filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/real.csv filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/test.csv filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/val.csv filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/y_test.npy filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/y_train.npy filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/y_val.npy filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/train_20260420_063042.log filter=lfs diff=lfs merge=lfs -textSynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/columns.json filter=lfs diff=lfs merge=lfs -text
123version https://git-lfs.github.com/spec/v1oid sha256:d28b60b361526450f0c203ddf50498854cb66ad5c1978516a99c265f529f8e4fsize 107696123version https://git-lfs.github.com/spec/v1oid sha256:7d8f85a52de0e63e292778c26cb06223383b366c589d4226c3de68b111ba5272size 849500123version https://git-lfs.github.com/spec/v1oid sha256:9ede9f1e2036e743d822e8ed8d7b5e1050159e8fc7b402b758a294f7a14528fesize 1081371234567{ "adapter_ready_status": "pass", "adapter_fail_reason_code": null, "adapter_fail_detail": null, "adapter_transforms_applied": [], "model_input_manifest": "/data/jialinzhang/SynthesizePipeline-server/output-SpecializedModels/c6/realtabformer/rtf-c6-20260329_231509/staged/realtabformer/model_input_manifest.json"}1[]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176{ "dataset_id": "c6", "model": "realtabformer", "target_column": "Type of Answer", "task_type": "classification", "column_schema": [ { "name": "Student ID", "role": "feature", "semantic_type": "numeric", "nullable": false, "missing_tokens": [], "parse_format": null, "impute_strategy": "median", "profile_stats": { "missing_rate": 0.0, "unique_count": 367, "unique_ratio": 0.048062, "example_values": [ "473", "351", "967", "1557", "394" ] } }, { "name": "Student Country", "role": "feature", "semantic_type": "categorical", "nullable": false, "missing_tokens": [], "parse_format": null, "impute_strategy": "mode", "profile_stats": { "missing_rate": 0.0, "unique_count": 8, "unique_ratio": 0.001048, "example_values": [ "Portugal", "Italy", "Lithuania", "Slovenia", "Ireland" ] } }, { "name": "Question ID", "role": "feature", "semantic_type": "numeric", "nullable": false, "missing_tokens": [], "parse_format": null, "impute_strategy": "median", "profile_stats": { "missing_rate": 0.0, "unique_count": 796, "unique_ratio": 0.104243, "example_values": [ "346", "796", "453", "87", "325" ] } }, { "name": "Type of Answer", "role": "target", "semantic_type": "boolean", "nullable": false, "missing_tokens": [], "parse_format": null, "impute_strategy": "mode", "profile_stats": { "missing_rate": 0.0, "unique_count": 2, "unique_ratio": 0.000262, "example_values": [ "0", "1" ] } }, { "name": "Question Level", "role": "feature", "semantic_type": "categorical", "nullable": false, "missing_tokens": [], "parse_format": null, "impute_strategy": "mode", "profile_stats": { "missing_rate": 0.0, "unique_count": 2, "unique_ratio": 0.000262, "example_values": [ "Advanced", "Basic" ] } }, { "name": "Topic", "role": "feature", "semantic_type": "text", "nullable": false, "missing_tokens": [], "parse_format": null, "impute_strategy": "keep_raw", "profile_stats": { "missing_rate": 0.0, "unique_count": 14, "unique_ratio": 0.001833, "example_values": [ "Complex Numbers", "Fundamental Mathematics", "Linear Algebra", "Real Functions of a single variable", "Analytic Geometry" ] } }, { "name": "Subtopic", "role": "feature", "semantic_type": "text", "nullable": false, "missing_tokens": [], "parse_format": null, "impute_strategy": "keep_raw", "profile_stats": { "missing_rate": 0.0, "unique_count": 24, "unique_ratio": 0.003143, "example_values": [ "Complex Numbers", "Algebraic expressions, Equations, and Inequalities", "Vector Spaces", "Limits and Continuity", "Linear Transformations" ] } }, { "name": "Keywords", "role": "feature", "semantic_type": "text", "nullable": false, "missing_tokens": [], "parse_format": null, "impute_strategy": "keep_raw", "profile_stats": { "missing_rate": 0.0, "unique_count": 360, "unique_ratio": 0.047145, "example_values": [ "Imaginary part,Modulus of a complex number,Operations with complex numbers,Conjugate number,Real part", "Logarithmic function,Exponential function,Simplify expressions", "Linear independence,Span,Linear dependence", "Indeterminate forms,Limits", "Range,Kernel" ] } } ], "public_manifest": "/data/jialinzhang/SynthesizePipeline-server/output-SpecializedModels/c6/realtabformer/rtf-c6-20260329_231509/public_gate/staged_input_manifest.json", "train_csv": "/data/jialinzhang/SynthesizePipeline-server/output-SpecializedModels/c6/realtabformer/rtf-c6-20260329_231509/staged/public/train.csv", "val_csv": "/data/jialinzhang/SynthesizePipeline-server/output-SpecializedModels/c6/realtabformer/rtf-c6-20260329_231509/staged/public/val.csv", "test_csv": "/data/jialinzhang/SynthesizePipeline-server/output-SpecializedModels/c6/realtabformer/rtf-c6-20260329_231509/staged/public/test.csv", "features_json": "/data/jialinzhang/SynthesizePipeline-server/output-SpecializedModels/c6/realtabformer/rtf-c6-20260329_231509/staged/public/staged_features.json", "public_gate_report": "/data/jialinzhang/SynthesizePipeline-server/output-SpecializedModels/c6/realtabformer/rtf-c6-20260329_231509/public_gate/public_gate_report.json"}123version https://git-lfs.github.com/spec/v1oid sha256:c593588546caea885c8bc0ad25f9b58eece87a5d47e6b0e2e9106d460b86ee73size 1707182123456789101112131415161718192021222324252627282930313233
import os, shutil, subprocess, sysroot = r"/workspace/ef-vfm"name = r"pipeline_ds"src = r"/work/output-SpecializedModels/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds"dst_data = os.path.join(root, "data", name)shutil.rmtree(dst_data, ignore_errors=True)shutil.copytree(src, dst_data)dst_syn = os.path.join(root, "synthetic", name)os.makedirs(dst_syn, exist_ok=True)for fn in ("real.csv", "test.csv", "val.csv"): shutil.copy(os.path.join(src, fn), os.path.join(dst_syn, fn))os.chdir(root)os.environ["PYTHONPATH"] = root + os.pathsep + os.environ.get("PYTHONPATH", "")subprocess.check_call([ sys.executable, "main.py", "--dataname", name, "--mode", "test", "--gpu", "0", "--no_wandb", "--exp_name", r"adapter_efvfm", "--ckpt_path", r"/workspace/ef-vfm/ef_vfm/ckpt/pipeline_ds/adapter_efvfm/model_500.pt", "--num_samples_to_generate", str(int(7636)),])base = os.path.join(root, "ef_vfm", "result", name, r"adapter_efvfm")best = Nonebest_t = -1.0for r, _, files in os.walk(base): if "samples.csv" in files: p = os.path.join(r, "samples.csv") t = os.path.getmtime(p) if t > best_t: best_t, best = t, pif not best: raise SystemExit("tabbyflow: no samples.csv in " + base)shutil.copy(best, r"/work/output-SpecializedModels/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabbyflow-c6-7636-20260420_063635.csv")12345678910111213141516171819202122
import os, shutil, subprocess, sysroot = r"/workspace/ef-vfm"name = r"pipeline_ds"src = r"/work/output-SpecializedModels/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds"os.makedirs(os.path.join(root, "data", name), exist_ok=True)dst_data = os.path.join(root, "data", name)dst_syn = os.path.join(root, "synthetic", name)shutil.rmtree(dst_data, ignore_errors=True)shutil.copytree(src, dst_data)os.makedirs(dst_syn, exist_ok=True)for fn in ("real.csv", "test.csv", "val.csv"): shutil.copy(os.path.join(src, fn), os.path.join(dst_syn, fn))os.chdir(root)os.environ["PYTHONPATH"] = root + os.pathsep + os.environ.get("PYTHONPATH", "")os.environ["EFVFM_SMOKE_STEPS"] = "500"os.environ["EFVFM_ADAPTER_TRAIN"] = "1"subprocess.check_call([ sys.executable, "main.py", "--dataname", name, "--mode", "train", "--gpu", "0", "--no_wandb", "--exp_name", r"adapter_efvfm",])123version https://git-lfs.github.com/spec/v1oid sha256:65e30301e80c06c9014ce49f064e87375a299ebf1c313175a5a08f32ab642619size 1350123version https://git-lfs.github.com/spec/v1oid sha256:adb734fec12f2251befd371dca69e481b19464aded2a6823105a01b4be6ddbe5size 40123version https://git-lfs.github.com/spec/v1oid sha256:065bdbcaaeac76f0cbdb0c5fff8891508d44a53a8e05c41f90aa9bc5e7681d87size 4158123version https://git-lfs.github.com/spec/v1oid sha256:caf5579c25c03b817ba8a8de781db7dc512fb35a1488a6e41f51f07997ce649bsize 921123version https://git-lfs.github.com/spec/v1oid sha256:220265cd461e79999e9e649a074b15d85f3dd699ad15a9e2e962233fc54ac96asize 4959123version https://git-lfs.github.com/spec/v1oid sha256:6724a1608a3f34120ee87e748ef97a39facca92eb7311fc0ae63e79e96901374size 621123version https://git-lfs.github.com/spec/v1oid sha256:bfdf5dc24983833c54d8dd0e6c39aaea73c21fb9552c8b7d60db4a3b4e2dc022size 783123version https://git-lfs.github.com/spec/v1oid sha256:d28b60b361526450f0c203ddf50498854cb66ad5c1978516a99c265f529f8e4fsize 107696123version https://git-lfs.github.com/spec/v1oid sha256:7d8f85a52de0e63e292778c26cb06223383b366c589d4226c3de68b111ba5272size 849500123version https://git-lfs.github.com/spec/v1oid sha256:9ede9f1e2036e743d822e8ed8d7b5e1050159e8fc7b402b758a294f7a14528fesize 108137123version https://git-lfs.github.com/spec/v1oid sha256:f3f152301852308e2ab1d6c5d6168600067b27234b3023c94bb3a2f404c893bdsize 322123version https://git-lfs.github.com/spec/v1oid sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945size 2123version https://git-lfs.github.com/spec/v1oid sha256:a06cceb0194640f866ac899656b3d24894841d175d9869695e607c5b01fe323esize 5157123version https://git-lfs.github.com/spec/v1oid sha256:277de07ba0e03cc33b5811f48ac3736def96875b4f7e5a45f721cf4e74e948a5size 562960123version https://git-lfs.github.com/spec/v1oid sha256:1bbe507388dc5629e9155e6ecf504bc121a9c227c10ff53532d15220fc65ee13size 78123version https://git-lfs.github.com/spec/v1oid sha256:0166d691afe31be41a6a7bcbd1c19508d44d02e52cc7aa9004aef843133a4565size 38368123version https://git-lfs.github.com/spec/v1oid sha256:13c6003f01f936249abb83aa4818534e23fae62a3b8d55c3f2751af25aa08122size 305568123version https://git-lfs.github.com/spec/v1oid sha256:c9b139a3150ceb04ef986bce457f05379562e57b6803a33e473206b4981b0870size 38288123version https://git-lfs.github.com/spec/v1oid sha256:eff443efa63dca8c3aa82fa2aa01653c220cf31d5e65e2e75f839f13a2dba5ebsize 7776123version https://git-lfs.github.com/spec/v1oid sha256:24258565807b5a7fc2c0c3c9a4f26f21a6bb9f8e60c004592425f19e3b2b55a1size 61216123version https://git-lfs.github.com/spec/v1oid sha256:00358b4aadd30d21f876db8493e7c6bd9c8a7d3900997d674d4e838eb4e6e5b7size 7760123version https://git-lfs.github.com/spec/v1oid sha256:ab0cd3dd2f27cc18d6d5b50be8ec3a3c586a22598ce1e96919f15001c5e9eb37size 1592123version https://git-lfs.github.com/spec/v1oid sha256:d54fcadad6523ae53e8c9a3cebe53bca7b4d404fdf04df8bd475e8353b3ab273size 174950123version https://git-lfs.github.com/spec/v1oid sha256:ef143d4543f0a65c6c7400acbe17848a1d895746e9834ab707b3234e6799d675size 21959123version https://git-lfs.github.com/spec/v1oid sha256:1df2b5b548fe565f4a33bd2798be543cad469f29ca7f32560e23aeb038827ae6size 21941123version https://git-lfs.github.com/spec/v1oid sha256:d4c747068f22f9e2e9c73161ef11c536909ed8a2e44445e33a0995a4bfb0dbd4size 7776123version https://git-lfs.github.com/spec/v1oid sha256:80ccc3344a1009b642b589707df9c94cbc3dfa53970e361d51fe44862d17d9f2size 61216123version https://git-lfs.github.com/spec/v1oid sha256:eb96c431016954da476d05276bc9daef4e208abfe3045dcaff0b65626c0ef3b1size 7760123version https://git-lfs.github.com/spec/v1oid sha256:ab434ed514852222d056742e0eda13b60c72167505932bcbd34f9895ff9f9b4esize 36081512345678910111213141516171819202122.DS_Store__pycache__/catboost_info/**/**.pt**/**.ipynb!agg_results.ipynb**/**.npy**/**.gz**/**.sh**/**.obj**/**.png**/**.tar**/**.code-workspace**/**.csvexp/**/**/results_catboost.jsonexp/**/**/results_mlp.json
configs/data/junk/RF/exps/123456789[submodule "ctgan"] # path = CTGAN/CTGAN url = https://github.com/sdv-dev/CTGAN[submodule "ctabgan"] # path = CTAB-GAN url = https://github.com/Team-TUD/CTAB-GAN[submodule "ctabgan+"] # path = CTAB-GAN-Plus url = https://github.com/Team-TUD/CTAB-GAN-Plus123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778# Description of .toml config for TabDDPMFirst of all, `train.T` and `eval.T` denote preprocessing for training and for evaluation, respectively.
Here we list non-obvious parameters.
Main part:- `seed = 0` -- evaluation seed (and training, but for training it is fixed to 0)- `parent_dir = "exp/abalone/check"` -- exp folder- `real_data_path = "data/abalone/"`- `model_type = "mlp"` -- model type that approximates the reverse process- `num_numerical_features ` -- a number of numerical features in dataset- `device = "cuda:0"`
Model params:- `is_y_cond` -- false for regression, true for classification- `d_in` -- input dimension (not necessary, since scripts calculate it automatically)- `num_calsses` -- zero for regression, a number of classes for classification- `rtdl_params` -- MLP parameters
```tomlseed = 0parent_dir = "exp/abalone/check"real_data_path = "data/abalone/"model_type = "mlp"num_numerical_features = 7device = "cuda:0"
[model_params]is_y_cond = falsed_in = 11num_classes = 0
[model_params.rtdl_params]d_layers = [ 256, 256,]dropout = 0.0
[diffusion_params]num_timesteps = 1000gaussian_loss_type = "mse"scheduler = "cosine"
[train.main]steps = 1000lr = 0.001weight_decay = 1e-05batch_size = 4096
[train.T]seed = 0normalization = "quantile"num_nan_policy = "__none__"cat_nan_policy = "__none__"cat_min_frequency = "__none__"cat_encoding = "__none__"y_policy = "default"
[sample]num_samples = 20800batch_size = 10000seed = 0
[eval.type]eval_model = "catboost"eval_type = "synthetic"
[eval.T]seed = 0normalization = "__none__"num_nan_policy = "__none__"cat_nan_policy = "__none__"cat_min_frequency = "__none__"cat_encoding = "__none__"y_policy = "default"
```1**/**.csv12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849# CTAB-GAN+This is the official git paper [CTAB-GAN+: Enhancing Tabular Data Synthesis](https://arxiv.org/abs/2204.00401). Current code is without differential privacy part.If you have any question, please contact `z.zhao-8@tudelft.nl` for more information.
## Prerequisite
The required package version```numpy==1.21.0torch==1.9.1pandas==1.2.4sklearn==0.24.1dython==0.6.4.post1scipy==1.4.1```The sklean package in newer version has updated its function for `sklearn.mixture.BayesianGaussianMixture`. Therefore, user should use this proposed sklearn version to successfully run the code!
## Example`Experiment_Script_Adult.ipynb` `Experiment_Script_king.ipynb` are two example notebooks for training CTAB-GAN+ with Adult (classification) and king (regression) datasets. The datasets are alread under `Real_Datasets` folder.The evaluation code is also provided.
## Problem type
You can either indicate your dataset problem type as Classification, Regression. If there is no problem type, you can leave the problem type as None as follows:```problem_type= {None: None}```
## For large dataset
If your dataset has large number of column, you may encounter the problem that our currnet code cannot encode all of your data since CTAB-GAN+ will wrap the encoded data into an image-like format. What you can do is changing the line 378 and 385 in `model/synthesizer/ctabgan_synthesizer.py`. The number in the `slide` list```sides = [4, 8, 16, 24, 32]```is the side size of image. You can enlarge the list to [4, 8, 16, 24, 32, 64] or [4, 8, 16, 24, 32, 64, 128] for accepting larger dataset.
## Bibtex
To cite this paper, you could use this bibtex
```@article{zhao2022ctab, title={CTAB-GAN+: Enhancing Tabular Data Synthesis}, author={Zhao, Zilong and Kunar, Aditya and Birke, Robert and Chen, Lydia Y}, journal={arXiv preprint arXiv:2204.00401}, year={2022}}```123version https://git-lfs.github.com/spec/v1oid sha256:f0d9e05a1c251995561cb1f4b2688be2c332a4971a0513d15645089efc0e236asize 435512345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970"""Generative model training algorithm based on the CTABGANSynthesiser
"""import pandas as pdimport timefrom model.pipeline.data_preparation import DataPrepfrom model.synthesizer.ctabgan_synthesizer import CTABGANSynthesizer
import warnings
warnings.filterwarnings("ignore")
class CTABGAN():
def __init__(self, df, test_ratio = 0.20, categorical_columns = [ 'workclass', 'education', 'marital-status', 'occupation', 'relationship', 'race', 'gender', 'native-country', 'income'], log_columns = [], mixed_columns= {'capital-loss':[0.0],'capital-gain':[0.0]}, general_columns = ["age"], non_categorical_columns = [], integer_columns = ['age', 'fnlwgt','capital-gain', 'capital-loss','hours-per-week'], problem_type= {"Classification": "income"}, class_dim=(256, 256, 256, 256), random_dim=100, num_channels=64, l2scale=1e-5, batch_size=500, epochs=150, device="cpu"):
self.__name__ = 'CTABGAN' self.synthesizer = CTABGANSynthesizer( class_dim=class_dim, random_dim=random_dim, num_channels=num_channels, l2scale=l2scale, batch_size=batch_size, epochs=epochs, device=device ) self.raw_df = df self.test_ratio = test_ratio self.categorical_columns = categorical_columns self.log_columns = log_columns self.mixed_columns = mixed_columns self.general_columns = general_columns self.non_categorical_columns = non_categorical_columns self.integer_columns = integer_columns self.problem_type = problem_type def fit(self): start_time = time.time() self.data_prep = DataPrep(self.raw_df,self.categorical_columns,self.log_columns,self.mixed_columns,self.general_columns,self.non_categorical_columns,self.integer_columns,self.problem_type,self.test_ratio) self.synthesizer.fit(train_data=self.data_prep.df, categorical = self.data_prep.column_types["categorical"], mixed = self.data_prep.column_types["mixed"], general = self.data_prep.column_types["general"], non_categorical = self.data_prep.column_types["non_categorical"], type=self.problem_type) end_time = time.time() print('Finished training in',end_time-start_time," seconds.")
def generate_samples(self, seed=0): sample = self.synthesizer.sample(len(self.raw_df), seed) sample_df = self.data_prep.inverse_prep(sample) return sample_df123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193import numpy as np
import pandas as pd
from sklearn import metrics
from sklearn import model_selection
from sklearn.preprocessing import MinMaxScaler,StandardScaler
from sklearn.neural_network import MLPClassifier
from sklearn.linear_model import LogisticRegression
from sklearn import svm,tree
from sklearn.ensemble import RandomForestClassifier
from dython.nominal import compute_associations
from scipy.stats import wasserstein_distance
from scipy.spatial import distance
import warnings
warnings.filterwarnings("ignore")
def supervised_model_training(x_train, y_train, x_test,
y_test, model_name):
if model_name == 'lr':
model = LogisticRegression(random_state=42,max_iter=500)
elif model_name == 'svm':
model = svm.SVC(random_state=42,probability=True)
elif model_name == 'dt':
model = tree.DecisionTreeClassifier(random_state=42)
elif model_name == 'rf':
model = RandomForestClassifier(random_state=42)
elif model_name == "mlp":
model = MLPClassifier(random_state=42,max_iter=100)
model.fit(x_train, y_train)
pred = model.predict(x_test)
if len(np.unique(y_train))>2:
predict = model.predict_proba(x_test)
acc = metrics.accuracy_score(y_test,pred)*100
auc = metrics.roc_auc_score(y_test, predict,average="weighted",multi_class="ovr")
f1_score = metrics.precision_recall_fscore_support(y_test, pred,average="weighted")[2]
return [acc, auc,f1_score]
else:
predict = model.predict_proba(x_test)[:,1]
acc = metrics.accuracy_score(y_test,pred)*100
auc = metrics.roc_auc_score(y_test, predict)
f1_score = metrics.precision_recall_fscore_support(y_test,pred)[2].mean()
return [acc, auc,f1_score]
def get_utility_metrics(real_path,fake_paths,scaler="MinMax",classifiers=["lr","dt","rf","mlp"],test_ratio=.20):
data_real = pd.read_csv(real_path).to_numpy()
data_dim = data_real.shape[1]
data_real_y = data_real[:,-1]
data_real_X = data_real[:,:data_dim-1]
X_train_real, X_test_real, y_train_real, y_test_real = model_selection.train_test_split(data_real_X ,data_real_y, test_size=test_ratio, stratify=data_real_y,random_state=42)
if scaler=="MinMax":
scaler_real = MinMaxScaler()
else:
scaler_real = StandardScaler()
scaler_real.fit(data_real_X)
X_train_real_scaled = scaler_real.transform(X_train_real)
X_test_real_scaled = scaler_real.transform(X_test_real)
all_real_results = []
for classifier in classifiers:
real_results = supervised_model_training(X_train_real_scaled,y_train_real,X_test_real_scaled,y_test_real,classifier)
all_real_results.append(real_results)
all_fake_results_avg = []
for fake_path in fake_paths:
data_fake = pd.read_csv(fake_path).to_numpy()
data_fake_y = data_fake[:,-1]
data_fake_X = data_fake[:,:data_dim-1]
X_train_fake, _ , y_train_fake, _ = model_selection.train_test_split(data_fake_X ,data_fake_y, test_size=test_ratio, stratify=data_fake_y,random_state=42)
if scaler=="MinMax":
scaler_fake = MinMaxScaler()
else:
scaler_fake = StandardScaler()
scaler_fake.fit(data_fake_X)
X_train_fake_scaled = scaler_fake.transform(X_train_fake)
all_fake_results = []
for classifier in classifiers:
fake_results = supervised_model_training(X_train_fake_scaled,y_train_fake,X_test_real_scaled,y_test_real,classifier)
all_fake_results.append(fake_results)
all_fake_results_avg.append(all_fake_results)
diff_results = np.array(all_real_results)- np.array(all_fake_results_avg).mean(axis=0)
return diff_results
def stat_sim(real_path,fake_path,cat_cols=None):
Stat_dict={}
real = pd.read_csv(real_path)
fake = pd.read_csv(fake_path)
really = real.copy()
fakey = fake.copy()
real_corr = compute_associations(real, nominal_columns=cat_cols)
fake_corr = compute_associations(fake, nominal_columns=cat_cols)
corr_dist = np.linalg.norm(real_corr - fake_corr)
cat_stat = []
num_stat = []
for column in real.columns:
if column in cat_cols:
real_pdf=(really[column].value_counts()/really[column].value_counts().sum())
fake_pdf=(fakey[column].value_counts()/fakey[column].value_counts().sum())
categories = (fakey[column].value_counts()/fakey[column].value_counts().sum()).keys().tolist()
sorted_categories = sorted(categories)
real_pdf_values = []
fake_pdf_values = []
for i in sorted_categories:
real_pdf_values.append(real_pdf[i])
fake_pdf_values.append(fake_pdf[i])
if len(real_pdf)!=len(fake_pdf):
zero_cats = set(really[column].value_counts().keys())-set(fakey[column].value_counts().keys())
for z in zero_cats:
real_pdf_values.append(real_pdf[z])
fake_pdf_values.append(0)
Stat_dict[column]=(distance.jensenshannon(real_pdf_values,fake_pdf_values, 2.0))
cat_stat.append(Stat_dict[column])
else:
scaler = MinMaxScaler()
scaler.fit(real[column].values.reshape(-1,1))
l1 = scaler.transform(real[column].values.reshape(-1,1)).flatten()
l2 = scaler.transform(fake[column].values.reshape(-1,1)).flatten()
Stat_dict[column]= (wasserstein_distance(l1,l2))
num_stat.append(Stat_dict[column])
return [np.mean(num_stat),np.mean(cat_stat),corr_dist]
def privacy_metrics(real_path,fake_path,data_percent=15):
real = pd.read_csv(real_path).drop_duplicates(keep=False)
fake = pd.read_csv(fake_path).drop_duplicates(keep=False)
real_refined = real.sample(n=int(len(real)*(.01*data_percent)), random_state=42).to_numpy()
fake_refined = fake.sample(n=int(len(fake)*(.01*data_percent)), random_state=42).to_numpy()
scalerR = StandardScaler()
scalerR.fit(real_refined)
scalerF = StandardScaler()
scalerF.fit(fake_refined)
df_real_scaled = scalerR.transform(real_refined)
df_fake_scaled = scalerF.transform(fake_refined)
dist_rf = metrics.pairwise_distances(df_real_scaled, Y=df_fake_scaled, metric='minkowski', n_jobs=-1)
dist_rr = metrics.pairwise_distances(df_real_scaled, Y=None, metric='minkowski', n_jobs=-1)
rd_dist_rr = dist_rr[~np.eye(dist_rr.shape[0],dtype=bool)].reshape(dist_rr.shape[0],-1)
dist_ff = metrics.pairwise_distances(df_fake_scaled, Y=None, metric='minkowski', n_jobs=-1)
rd_dist_ff = dist_ff[~np.eye(dist_ff.shape[0],dtype=bool)].reshape(dist_ff.shape[0],-1)
smallest_two_indexes_rf = [dist_rf[i].argsort()[:2] for i in range(len(dist_rf))]
smallest_two_rf = [dist_rf[i][smallest_two_indexes_rf[i]] for i in range(len(dist_rf))]
smallest_two_indexes_rr = [rd_dist_rr[i].argsort()[:2] for i in range(len(rd_dist_rr))]
smallest_two_rr = [rd_dist_rr[i][smallest_two_indexes_rr[i]] for i in range(len(rd_dist_rr))]
smallest_two_indexes_ff = [rd_dist_ff[i].argsort()[:2] for i in range(len(rd_dist_ff))]
smallest_two_ff = [rd_dist_ff[i][smallest_two_indexes_ff[i]] for i in range(len(rd_dist_ff))]
nn_ratio_rr = np.array([i[0]/i[1] for i in smallest_two_rr])
nn_ratio_ff = np.array([i[0]/i[1] for i in smallest_two_ff])
nn_ratio_rf = np.array([i[0]/i[1] for i in smallest_two_rf])
nn_fifth_perc_rr = np.percentile(nn_ratio_rr,5)
nn_fifth_perc_ff = np.percentile(nn_ratio_ff,5)
nn_fifth_perc_rf = np.percentile(nn_ratio_rf,5)
min_dist_rf = np.array([i[0] for i in smallest_two_rf])
fifth_perc_rf = np.percentile(min_dist_rf,5)
min_dist_rr = np.array([i[0] for i in smallest_two_rr])
fifth_perc_rr = np.percentile(min_dist_rr,5)
min_dist_ff = np.array([i[0] for i in smallest_two_ff])
fifth_perc_ff = np.percentile(min_dist_ff,5)
return np.array([fifth_perc_rf,fifth_perc_rr,fifth_perc_ff,nn_fifth_perc_rf,nn_fifth_perc_rr,nn_fifth_perc_ff]).reshape(1,6) 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130import numpy as npimport pandas as pdfrom sklearn import preprocessingfrom sklearn import model_selection
class DataPrep(object): def __init__(self, raw_df: pd.DataFrame, categorical: list, log:list, mixed:dict, general:list, non_categorical:list, integer:list, type:dict, test_ratio:float): self.categorical_columns = categorical self.log_columns = log self.mixed_columns = mixed self.general_columns = general self.non_categorical_columns = non_categorical self.integer_columns = integer self.column_types = dict() self.column_types["categorical"] = [] self.column_types["mixed"] = {} self.column_types["general"] = [] self.column_types["non_categorical"] = [] self.lower_bounds = {} self.label_encoder_list = [] target_col = list(type.values())[0] if target_col is not None: y_real = raw_df[target_col] X_real = raw_df.drop(columns=[target_col]) X_train_real, _, y_train_real, _ = model_selection.train_test_split(X_real ,y_real, test_size=test_ratio, stratify=y_real,random_state=42) X_train_real[target_col]= y_train_real
self.df = X_train_real else: self.df = raw_df
self.df = self.df.replace(r' ', np.nan) self.df = self.df.fillna('empty') all_columns= set(self.df.columns) irrelevant_missing_columns = set(self.categorical_columns) relevant_missing_columns = list(all_columns - irrelevant_missing_columns) for i in relevant_missing_columns: if i in self.log_columns: if "empty" in list(self.df[i].values): self.df[i] = self.df[i].apply(lambda x: -9999999 if x=="empty" else x) self.mixed_columns[i] = [-9999999] elif i in list(self.mixed_columns.keys()): if "empty" in list(self.df[i].values): self.df[i] = self.df[i].apply(lambda x: -9999999 if x=="empty" else x ) self.mixed_columns[i].append(-9999999) else: if "empty" in list(self.df[i].values): self.df[i] = self.df[i].apply(lambda x: -9999999 if x=="empty" else x) self.mixed_columns[i] = [-9999999] if self.log_columns: for log_column in self.log_columns: valid_indices = [] for idx,val in enumerate(self.df[log_column].values): if val!=-9999999: valid_indices.append(idx) eps = 1 lower = np.min(self.df[log_column].iloc[valid_indices].values) self.lower_bounds[log_column] = lower if lower>0: self.df[log_column] = self.df[log_column].apply(lambda x: np.log(x) if x!=-9999999 else -9999999) elif lower == 0: self.df[log_column] = self.df[log_column].apply(lambda x: np.log(x+eps) if x!=-9999999 else -9999999) else: self.df[log_column] = self.df[log_column].apply(lambda x: np.log(x-lower+eps) if x!=-9999999 else -9999999)
for column_index, column in enumerate(self.df.columns): if column in self.categorical_columns: label_encoder = preprocessing.LabelEncoder() self.df[column] = self.df[column].astype(str) label_encoder.fit(self.df[column]) current_label_encoder = dict() current_label_encoder['column'] = column current_label_encoder['label_encoder'] = label_encoder transformed_column = label_encoder.transform(self.df[column]) self.df[column] = transformed_column self.label_encoder_list.append(current_label_encoder) self.column_types["categorical"].append(column_index)
if column in self.general_columns: self.column_types["general"].append(column_index) if column in self.non_categorical_columns: self.column_types["non_categorical"].append(column_index) elif column in self.mixed_columns: self.column_types["mixed"][column_index] = self.mixed_columns[column] elif column in self.general_columns: self.column_types["general"].append(column_index)
super().__init__() def inverse_prep(self, data, eps=1): df_sample = pd.DataFrame(data,columns=self.df.columns) for i in range(len(self.label_encoder_list)): le = self.label_encoder_list[i]["label_encoder"] df_sample[self.label_encoder_list[i]["column"]] = df_sample[self.label_encoder_list[i]["column"]].astype(int) df_sample[self.label_encoder_list[i]["column"]] = le.inverse_transform(df_sample[self.label_encoder_list[i]["column"]])
if self.log_columns: for i in df_sample: if i in self.log_columns: lower_bound = self.lower_bounds[i] if lower_bound>0: df_sample[i].apply(lambda x: np.exp(x)) elif lower_bound==0: df_sample[i] = df_sample[i].apply(lambda x: np.ceil(np.exp(x)-eps) if (np.exp(x)-eps) < 0 else (np.exp(x)-eps)) else: df_sample[i] = df_sample[i].apply(lambda x: np.exp(x)-eps+lower_bound)
if self.integer_columns: for column in self.integer_columns: df_sample[column]= (np.round(df_sample[column].values)) df_sample[column] = df_sample[column].astype(int)
df_sample.replace(-9999999, np.nan,inplace=True) df_sample.replace('empty', np.nan,inplace=True)
return df_sample123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280from __future__ import absolute_importfrom __future__ import divisionfrom __future__ import print_function
import mathimport sys
import numpy as npfrom scipy import specialimport six
######################### LOG-SPACE ARITHMETIC #########################
def _log_add(logx, logy): """Add two numbers in the log space.""" a, b = min(logx, logy), max(logx, logy) if a == -np.inf: # adding 0 return b # Use exp(a) + exp(b) = (exp(a - b) + 1) * exp(b) return math.log1p(math.exp(a - b)) + b # log1p(x) = log(x + 1)
def _log_sub(logx, logy): """Subtract two numbers in the log space. Answer must be non-negative.""" if logx < logy: raise ValueError("The result of subtraction must be non-negative.") if logy == -np.inf: # subtracting 0 return logx if logx == logy: return -np.inf # 0 is represented as -np.inf in the log space.
try: # Use exp(x) - exp(y) = (exp(x - y) - 1) * exp(y). return math.log(math.expm1(logx - logy)) + logy # expm1(x) = exp(x) - 1 except OverflowError: return logx
def _log_print(logx): """Pretty print.""" if logx < math.log(sys.float_info.max): return "{}".format(math.exp(logx)) else: return "exp({})".format(logx)
def _compute_log_a_int(q, sigma, alpha): """Compute log(A_alpha) for integer alpha. 0 < q < 1.""" assert isinstance(alpha, six.integer_types)
# Initialize with 0 in the log space. log_a = -np.inf
for i in range(alpha + 1): log_coef_i = ( math.log(special.binom(alpha, i)) + i * math.log(q) + (alpha - i) * math.log(1 - q))
s = log_coef_i + (i * i - i) / (2 * (sigma**2)) log_a = _log_add(log_a, s)
return float(log_a)
def _compute_log_a_frac(q, sigma, alpha): """Compute log(A_alpha) for fractional alpha. 0 < q < 1.""" # The two parts of A_alpha, integrals over (-inf,z0] and [z0, +inf), are # initialized to 0 in the log space: log_a0, log_a1 = -np.inf, -np.inf i = 0
z0 = sigma**2 * math.log(1 / q - 1) + .5
while True: # do ... until loop coef = special.binom(alpha, i) log_coef = math.log(abs(coef)) j = alpha - i
log_t0 = log_coef + i * math.log(q) + j * math.log(1 - q) log_t1 = log_coef + j * math.log(q) + i * math.log(1 - q)
log_e0 = math.log(.5) + _log_erfc((i - z0) / (math.sqrt(2) * sigma)) log_e1 = math.log(.5) + _log_erfc((z0 - j) / (math.sqrt(2) * sigma))
log_s0 = log_t0 + (i * i - i) / (2 * (sigma**2)) + log_e0 log_s1 = log_t1 + (j * j - j) / (2 * (sigma**2)) + log_e1
if coef > 0: log_a0 = _log_add(log_a0, log_s0) log_a1 = _log_add(log_a1, log_s1) else: log_a0 = _log_sub(log_a0, log_s0) log_a1 = _log_sub(log_a1, log_s1)
i += 1 if max(log_s0, log_s1) < -30: break
return _log_add(log_a0, log_a1)
def _compute_log_a(q, sigma, alpha): """Compute log(A_alpha) for any positive finite alpha.""" if float(alpha).is_integer(): return _compute_log_a_int(q, sigma, int(alpha)) else: return _compute_log_a_frac(q, sigma, alpha)
def _log_erfc(x): """Compute log(erfc(x)) with high accuracy for large x.""" try: return math.log(2) + special.log_ndtr(-x * 2**.5) except NameError: # If log_ndtr is not available, approximate as follows: r = special.erfc(x) if r == 0.0: # Using the Laurent series at infinity for the tail of the erfc function: # erfc(x) ~ exp(-x^2-.5/x^2+.625/x^4)/(x*pi^.5) # To verify in Mathematica: # Series[Log[Erfc[x]] + Log[x] + Log[Pi]/2 + x^2, {x, Infinity, 6}] return (-math.log(math.pi) / 2 - math.log(x) - x**2 - .5 * x**-2 + .625 * x**-4 - 37. / 24. * x**-6 + 353. / 64. * x**-8) else: return math.log(r)
def _compute_delta(orders, rdp, eps): """Compute delta given a list of RDP values and target epsilon.
Args: orders: An array (or a scalar) of orders. rdp: A list (or a scalar) of RDP guarantees. eps: The target epsilon.
Returns: Pair of (delta, optimal_order).
Raises: ValueError: If input is malformed.
""" orders_vec = np.atleast_1d(orders) rdp_vec = np.atleast_1d(rdp)
if len(orders_vec) != len(rdp_vec): raise ValueError("Input lists must have the same length.")
deltas = np.exp((rdp_vec - eps) * (orders_vec - 1)) idx_opt = np.argmin(deltas) return min(deltas[idx_opt], 1.), orders_vec[idx_opt]
def _compute_eps(orders, rdp, delta): """Compute epsilon given a list of RDP values and target delta.
Args: orders: An array (or a scalar) of orders. rdp: A list (or a scalar) of RDP guarantees. delta: The target delta.
Returns: Pair of (eps, optimal_order).
Raises: ValueError: If input is malformed.
""" orders_vec = np.atleast_1d(orders) rdp_vec = np.atleast_1d(rdp)
if len(orders_vec) != len(rdp_vec): raise ValueError("Input lists must have the same length.")
eps = rdp_vec - math.log(delta) / (orders_vec - 1)
idx_opt = np.nanargmin(eps) # Ignore NaNs return eps[idx_opt], orders_vec[idx_opt]
def _compute_rdp(q, sigma, alpha): """Compute RDP of the Sampled Gaussian mechanism at order alpha.
Args: q: The sampling rate. sigma: The std of the additive Gaussian noise. alpha: The order at which RDP is computed.
Returns: RDP at alpha, can be np.inf. """ if q == 0: return 0
if q == 1.: return alpha / (2 * sigma**2)
if np.isinf(alpha): return np.inf
return _compute_log_a(q, sigma, alpha) / (alpha - 1)
def compute_rdp(q, noise_multiplier, steps, orders): """Compute RDP of the Sampled Gaussian Mechanism.
Args: q: The sampling rate. noise_multiplier: The ratio of the standard deviation of the Gaussian noise to the l2-sensitivity of the function to which it is added. steps: The number of steps. orders: An array (or a scalar) of RDP orders.
Returns: The RDPs at all orders, can be np.inf. """ if np.isscalar(orders): rdp = _compute_rdp(q, noise_multiplier, orders) else: rdp = np.array([_compute_rdp(q, noise_multiplier, order) for order in orders])
return rdp * steps
def get_privacy_spent(orders, rdp, target_eps=None, target_delta=None): """Compute delta (or eps) for given eps (or delta) from RDP values.
Args: orders: An array (or a scalar) of RDP orders. rdp: An array of RDP values. Must be of the same length as the orders list. target_eps: If not None, the epsilon for which we compute the corresponding delta. target_delta: If not None, the delta for which we compute the corresponding epsilon. Exactly one of target_eps and target_delta must be None.
Returns: eps, delta, opt_order.
Raises: ValueError: If target_eps and target_delta are messed up. """ if target_eps is None and target_delta is None: raise ValueError( "Exactly one out of eps and delta must be None. (Both are).")
if target_eps is not None and target_delta is not None: raise ValueError( "Exactly one out of eps and delta must be None. (None is).")
if target_eps is not None: delta, opt_order = _compute_delta(orders, rdp, target_eps) return target_eps, delta, opt_order else: eps, opt_order = _compute_eps(orders, rdp, target_delta) return eps, target_delta, opt_order
def compute_rdp_from_ledger(ledger, orders): """Compute RDP of Sampled Gaussian Mechanism from ledger.
Args: ledger: A formatted privacy ledger. orders: An array (or a scalar) of RDP orders.
Returns: RDP at all orders, can be np.inf. """ total_rdp = np.zeros_like(orders, dtype=float) for sample in ledger: # Compute equivalent z from l2_clip_bounds and noise stddevs in sample. # See https://arxiv.org/pdf/1812.06210.pdf for derivation of this formula. effective_z = sum([ (q.noise_stddev / q.l2_norm_bound)**-2 for q in sample.queries])**-0.5 total_rdp += compute_rdp( sample.selection_probability, effective_z, 1, orders) return total_rdp.gitattributes+34
SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/public/test.csvAdded+3
SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/public/train.csvAdded+3
SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/public/val.csvAdded+3
SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/realtabformer/adapter_report.jsonAdded+7
SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/realtabformer/adapter_transforms_applied.jsonAdded+1
SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/staged/realtabformer/model_input_manifest.jsonAdded+176
SynthData0523/main/c6/realtabformer/rtf-c6-20260329_231509/train_20260329_231510.logAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/_tabbyflow_gen.pyAdded+33
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/_tabbyflow_train.pyAdded+22
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/input_snapshot.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/models_tabbyflow/trained.ptAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/public_gate/normalized_schema_snapshot.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/public_gate/public_gate_report.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/public_gate/staged_input_manifest.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/runtime_result.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/staged_features.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/test.csvAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/train.csvAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/public/val.csvAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/tabbyflow/adapter_report.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/tabbyflow/adapter_transforms_applied.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/staged/tabbyflow/model_input_manifest.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabbyflow-c6-7636-20260420_063635.csvAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabbyflow_train_meta.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_cat_test.npyAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_cat_train.npyAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_cat_val.npyAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_num_test.npyAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_num_train.npyAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/X_num_val.npyAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/info.jsonAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/real.csvAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/test.csvAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/val.csvAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/y_test.npyAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/y_train.npyAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/tabular_bundle/pipeline_ds/y_val.npyAdded+3
SynthData0523/main/c6/tabbyflow/tabbyflow-c6-20260420_063042/train_20260420_063042.logAdded+3
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/._dataAdded
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/.gitignoreAdded+22
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/.gitmodulesAdded+9
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CONFIG_DESCRIPTION.mdAdded+78
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/.gitignoreAdded+1
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/README.mdAdded+49
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/columns.jsonAdded+3
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/model copy/ctabgan.pyAdded+70
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/model copy/eval/evaluation.pyAdded+193
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/model copy/pipeline/data_preparation.pyAdded+130
SynthData0523/main/c6/tabddpm/tabddpm-c6-20260510_222430/_tabddpm_runtime/CTAB-GAN-Plus/model copy/privacy_utils/rdp_accountant.pyAdded+280