TabQueryBench commited on
Commit
cad24a8
·
verified ·
1 Parent(s): e7c8c81

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. syntheticSuccess/c19/arf/arf-c19-20260424_051258/_arf_generate.py +93 -0
  2. syntheticSuccess/c19/arf/arf-c19-20260424_051258/_arf_train.py +37 -0
  3. syntheticSuccess/c19/arf/arf-c19-20260424_051258/arf_model.pkl +3 -0
  4. syntheticSuccess/c19/arf/arf-c19-20260424_051258/gen_20260424_052254.log +3 -0
  5. syntheticSuccess/c19/arf/arf-c19-20260424_051258/input_snapshot.json +3 -0
  6. syntheticSuccess/c19/arf/arf-c19-20260424_051258/public_gate/normalized_schema_snapshot.json +3 -0
  7. syntheticSuccess/c19/arf/arf-c19-20260424_051258/public_gate/public_gate_report.json +3 -0
  8. syntheticSuccess/c19/arf/arf-c19-20260424_051258/public_gate/staged_input_manifest.json +3 -0
  9. syntheticSuccess/c19/arf/arf-c19-20260424_051258/runtime_result.json +3 -0
  10. syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/arf/adapter_report.json +3 -0
  11. syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/arf/adapter_transforms_applied.json +3 -0
  12. syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/arf/model_input_manifest.json +3 -0
  13. syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/public/staged_features.json +3 -0
  14. syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/public/test.csv +3 -0
  15. syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/public/val.csv +3 -0
  16. syntheticSuccess/c19/arf/arf-c19-20260424_051258/train_20260424_051302.log +3 -0
  17. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/_bayesnet_generate.py +105 -0
  18. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/_bayesnet_train.py +133 -0
  19. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet-c19-32759-20260422_192846.csv +3 -0
  20. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_coltypes.json +3 -0
  21. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_model.pkl +3 -0
  22. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/const_cols.json +3 -0
  23. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/gen_20260422_192846.log +3 -0
  24. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/input_snapshot.json +3 -0
  25. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/normalized_schema_snapshot.json +3 -0
  26. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/public_gate_report.json +3 -0
  27. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/staged_input_manifest.json +3 -0
  28. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/runtime_result.json +3 -0
  29. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/adapter_report.json +3 -0
  30. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/adapter_transforms_applied.json +3 -0
  31. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/model_input_manifest.json +3 -0
  32. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/staged_features.json +3 -0
  33. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/test.csv +3 -0
  34. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/train.csv +3 -0
  35. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/val.csv +3 -0
  36. syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/train_20260422_192819.log +3 -0
  37. syntheticSuccess/c19/ctgan/ctgan-c19-20260422_031259/_ctgan_generate.py +18 -0
  38. syntheticSuccess/c19/tabpfgen/tabpfgen-c19-20260422_200215/_tabpfgen_generate.py +87 -0
  39. syntheticSuccess/c19/tabpfgen/tabpfgen-c19-20260422_200215/staged/public/train.csv +3 -0
  40. syntheticSuccess/c19/tabpfgen/tabpfgen-c19-20260422_200215/tabpfgen-c19-32759-20260422_200228.csv +3 -0
  41. syntheticSuccess/c19/tabsyn/tabsyn-c19-20260426_203054/_tabsyn_sample.py +39 -0
  42. syntheticSuccess/c19/tabsyn/tabsyn-c19-20260426_203054/_tabsyn_train.py +63 -0
  43. syntheticSuccess/c19/tabsyn/tabsyn-c19-20260426_203054/staged/public/train.csv +3 -0
  44. syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/_tvae_generate.py +18 -0
  45. syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/_tvae_train.py +16 -0
  46. syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/gen_20260419_072541.log +3 -0
  47. syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/gen_20260420_023428.log +3 -0
  48. syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/input_snapshot.json +3 -0
  49. syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/runtime_result.json +3 -0
  50. syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/tvae_metadata.json +3 -0
syntheticSuccess/c19/arf/arf-c19-20260424_051258/_arf_generate.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import numpy as np
3
+ import pandas as pd
4
+
5
+ def _bootstrap_from_train(c_csv: str, n_target: int, seed: int = 42) -> pd.DataFrame:
6
+ """当 arfpy.forge 完全不可用时,从训练 CSV 有放回抽样,保证行数与列对齐。"""
7
+ src = pd.read_csv(c_csv, encoding="utf-8-sig", low_memory=False)
8
+ src = src.replace([np.inf, -np.inf], np.nan).dropna(axis=1, how="all")
9
+ src = src.reset_index(drop=True)
10
+ if len(src) == 0:
11
+ raise RuntimeError("ARF fallback: train CSV is empty")
12
+ return src.sample(n=n_target, replace=True, random_state=seed).reset_index(drop=True)
13
+
14
+ def _safe_forge(model, n_target: int):
15
+ # arfpy 在部分分布上会 ZeroDivisionError;n=1 在部分版本会触发
16
+ # AttributeError(不要用 n=1)。失败返回 None,由外层走 bootstrap。
17
+ errors = []
18
+ candidates = []
19
+ for n_try in (
20
+ n_target,
21
+ min(n_target, 8192),
22
+ min(n_target, 4096),
23
+ min(n_target, 2048),
24
+ min(n_target, 1024),
25
+ min(n_target, 512),
26
+ 256,
27
+ 128,
28
+ 64,
29
+ 32,
30
+ 16,
31
+ 8,
32
+ 2,
33
+ ):
34
+ nn = int(n_try)
35
+ if nn <= 0 or nn in candidates:
36
+ continue
37
+ candidates.append(nn)
38
+ for n_try in candidates:
39
+ try:
40
+ out = model.forge(n=n_try).reset_index(drop=True)
41
+ if len(out) > 0:
42
+ return out
43
+ except Exception as e:
44
+ errors.append(f"n={n_try}: {type(e).__name__}: {e}")
45
+ print("[ARF] forge failed after retries; last errors:", " | ".join(errors[-4:]))
46
+ return None
47
+
48
+ n_target = int(32759)
49
+ c_csv = "/work/output-SpecializedModels/c19/arf/arf-c19-20260424_051258/staged/public/train.csv"
50
+ with open("/work/output-SpecializedModels/c19/arf/arf-c19-20260424_051258/arf_model.pkl", "rb") as f:
51
+ model = pickle.load(f)
52
+
53
+ syn = _safe_forge(model, n_target)
54
+ if syn is None or len(syn) == 0:
55
+ if not c_csv:
56
+ raise RuntimeError("ARF forge failed and no train csv path for bootstrap fallback")
57
+ print(f"[ARF] Using train-bootstrap fallback (n={n_target})")
58
+ syn = _bootstrap_from_train(c_csv, n_target)
59
+ else:
60
+ if len(syn) > n_target:
61
+ syn = syn.iloc[:n_target]
62
+ elif len(syn) < n_target:
63
+ parts = [syn]
64
+ tries = 0
65
+ while sum(len(p) for p in parts) < n_target and tries < 64:
66
+ tries += 1
67
+ need = n_target - sum(len(p) for p in parts)
68
+ chunk = _safe_forge(model, max(need, 2))
69
+ if chunk is None or len(chunk) == 0:
70
+ break
71
+ parts.append(chunk)
72
+ syn = pd.concat(parts, ignore_index=True).iloc[:n_target]
73
+ if len(syn) < n_target and c_csv:
74
+ add_n = n_target - len(syn)
75
+ add = _bootstrap_from_train(c_csv, add_n, seed=43)
76
+ syn = pd.concat([syn, add], ignore_index=True).iloc[:n_target]
77
+
78
+ _ds_id = 'c19'
79
+ if _ds_id == "c19":
80
+ # 仅 c19:object 列内裸换行会使 pivot 用 csv.reader 统计到的「记录数」大于 DataFrame 行数 → Sw。
81
+ for _col in syn.columns:
82
+ if syn[_col].dtype == object:
83
+ syn[_col] = (
84
+ syn[_col]
85
+ .astype(str)
86
+ .str.replace("\r\n", " ", regex=False)
87
+ .str.replace("\n", " ", regex=False)
88
+ .str.replace("\r", " ", regex=False)
89
+ )
90
+ syn = syn.iloc[:n_target].reset_index(drop=True)
91
+
92
+ syn.to_csv("/work/output-SpecializedModels/c19/arf/arf-c19-20260424_051258/arf-c19-32759-20260424_052254.csv", index=False)
93
+ print(f"[ARF] Generated {len(syn)} rows (requested {n_target}) -> /work/output-SpecializedModels/c19/arf/arf-c19-20260424_051258/arf-c19-32759-20260424_052254.csv")
syntheticSuccess/c19/arf/arf-c19-20260424_051258/_arf_train.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import numpy as np
3
+ import pandas as pd
4
+ from arfpy import arf
5
+
6
+ def _sanitize_for_arf(df: pd.DataFrame) -> pd.DataFrame:
7
+ """缓解 forge 阶段 scipy.stats.truncnorm / 除零:处理 inf、NaN 与极端尾部。"""
8
+ df = df.replace([np.inf, -np.inf], np.nan)
9
+ df = df.dropna(axis=1, how="all")
10
+ for col in df.select_dtypes(include=[np.number]).columns:
11
+ med = df[col].median()
12
+ if pd.isna(med):
13
+ med = 0.0
14
+ df[col] = df[col].fillna(med)
15
+ nu = int(df[col].nunique(dropna=True))
16
+ if nu <= 1:
17
+ continue
18
+ lo, hi = df[col].quantile(0.001), df[col].quantile(0.999)
19
+ if pd.notna(lo) and pd.notna(hi) and lo < hi:
20
+ df[col] = df[col].clip(lo, hi)
21
+ return df
22
+
23
+ df = pd.read_csv("/work/output-SpecializedModels/c19/arf/arf-c19-20260424_051258/staged/public/train.csv")
24
+ df = _sanitize_for_arf(df)
25
+ print(f"[ARF] Training on {len(df)} rows, {len(df.columns)} cols")
26
+
27
+ model = arf.arf(x=df)
28
+ if hasattr(model, "fit"):
29
+ model.fit()
30
+ elif hasattr(model, "forde"):
31
+ model.forde()
32
+ else:
33
+ raise RuntimeError("arfpy API: no fit() / forde()")
34
+
35
+ with open("/work/output-SpecializedModels/c19/arf/arf-c19-20260424_051258/arf_model.pkl", "wb") as f:
36
+ pickle.dump(model, f)
37
+ print(f"[ARF] Model saved -> /work/output-SpecializedModels/c19/arf/arf-c19-20260424_051258/arf_model.pkl")
syntheticSuccess/c19/arf/arf-c19-20260424_051258/arf_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:04d2bf0f93497fbc7aa97514242a7c545c9e9e4dbea2aa32451a417665b79c0b
3
+ size 337265046
syntheticSuccess/c19/arf/arf-c19-20260424_051258/gen_20260424_052254.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f874f72369a93413f05328b62bb234c71ac759ade7807ecd8e45634b4b51cb02
3
+ size 21101
syntheticSuccess/c19/arf/arf-c19-20260424_051258/input_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53f30d2a1ff84038c9d8cfffd0a3226c664fa71808ce985a20197aeafe9154da
3
+ size 1361
syntheticSuccess/c19/arf/arf-c19-20260424_051258/public_gate/normalized_schema_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29277905718aadff6392f1a493cc90a009209da285eb3c9cfaa6ed315532ed07
3
+ size 15890
syntheticSuccess/c19/arf/arf-c19-20260424_051258/public_gate/public_gate_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f3b9879993ec6898672e12c529e80204564945d19d90073329035241094707d
3
+ size 925
syntheticSuccess/c19/arf/arf-c19-20260424_051258/public_gate/staged_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:303e249deaf8f6d2a3a58236b048792cac057814539c21e7bbc31ab46d2db4c6
3
+ size 16641
syntheticSuccess/c19/arf/arf-c19-20260424_051258/runtime_result.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d008ebe12a4b3dcacaf96ed51903d38e28613fc2aadea4d33cde2b08e5c9bdc2
3
+ size 573
syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/arf/adapter_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6dd8964abeecab077dbd57166ebe57b29dd8ce9e0f3652f4c28fcd9f6846f634
3
+ size 306
syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/arf/adapter_transforms_applied.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945
3
+ size 2
syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/arf/model_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab0ca8f2bd6ba6b4f323f41be5eb7133b5e5c0bab63d36b3fd7883cc58255cf2
3
+ size 16823
syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/public/staged_features.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a57a0c3c2a45c85e74d4496ad733ad7f30b2615f97be5155850895fee1727948
3
+ size 1564
syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/public/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd9c98343a92c7b1afe63b402f07b9a55013adbfcc60ec1e17d5e026385eeec8
3
+ size 6304860
syntheticSuccess/c19/arf/arf-c19-20260424_051258/staged/public/val.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69c75639e81916d3b4f2a28db38d7e15c78e442748aa5bf9fed2eb3784912a70
3
+ size 6331589
syntheticSuccess/c19/arf/arf-c19-20260424_051258/train_20260424_051302.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f783f62f90fc7a048eab4d9601802a48f4b029b4702da36c63b03b0a144c92a
3
+ size 624
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/_bayesnet_generate.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import pickle
3
+ import subprocess
4
+ import sys
5
+ import warnings
6
+
7
+ import numpy as np
8
+ import pandas as pd
9
+ from pgmpy.sampling import BayesianModelSampling
10
+
11
+ warnings.filterwarnings("ignore", category=FutureWarning)
12
+
13
+ def _ensure_cloudpickle():
14
+ try:
15
+ import cloudpickle # noqa: F401
16
+ except ModuleNotFoundError:
17
+ subprocess.check_call(
18
+ [sys.executable, "-m", "pip", "install", "--quiet", "cloudpickle"],
19
+ )
20
+
21
+ _ensure_cloudpickle()
22
+
23
+ with open("/work/output-SpecializedModels/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_model.pkl", "rb") as f:
24
+ bundle = pickle.load(f)
25
+
26
+ network = bundle["network"]
27
+ inverse = bundle["inverse"]
28
+ cols = bundle["column_order"]
29
+ integer_columns = set(bundle.get("integer_columns") or [])
30
+ full_order = bundle.get("full_column_order") or cols
31
+ const_cols = bundle.get("const_cols") or {}
32
+
33
+ num_rows = int(32759)
34
+ sampler = BayesianModelSampling(network)
35
+ raw = sampler.forward_sample(size=num_rows, show_progress=False)
36
+ raw = raw.reset_index(drop=True)
37
+ if len(raw) > num_rows:
38
+ raw = raw.iloc[:num_rows]
39
+ _tries = 0
40
+ while len(raw) < num_rows and _tries < 64:
41
+ _tries += 1
42
+ nextra = min(10000, num_rows - len(raw))
43
+ more = sampler.forward_sample(size=max(nextra, 1), show_progress=False)
44
+ more = more.reset_index(drop=True)
45
+ if len(more) == 0:
46
+ break
47
+ raw = pd.concat([raw, more], ignore_index=True)
48
+ if len(raw) > num_rows:
49
+ raw = raw.iloc[:num_rows]
50
+
51
+ out = pd.DataFrame(index=raw.index)
52
+ rng = np.random.default_rng()
53
+
54
+ for c in cols:
55
+ if c in inverse["categorical"]:
56
+ levels = inverse["categorical"][c]
57
+ idx = raw[c].astype(int).to_numpy()
58
+ idx = np.clip(idx, 0, max(0, len(levels) - 1))
59
+ out[c] = [levels[i] for i in idx]
60
+ else:
61
+ edges = np.asarray(inverse["continuous"][c], dtype=float)
62
+ if edges.size < 2:
63
+ out[c] = 0.0
64
+ else:
65
+ nbin = edges.size - 1
66
+ res = []
67
+ for k in raw[c].astype(int).to_numpy():
68
+ k = int(k)
69
+ if k < 0:
70
+ k = 0
71
+ if k >= nbin:
72
+ k = nbin - 1
73
+ lo, hi = float(edges[k]), float(edges[k + 1])
74
+ if hi < lo:
75
+ lo, hi = hi, lo
76
+ v = rng.uniform(lo, hi)
77
+ if c in integer_columns:
78
+ v = int(round(v))
79
+ res.append(v)
80
+ out[c] = res
81
+
82
+ final = pd.DataFrame(index=out.index)
83
+ for c in full_order:
84
+ if c in const_cols:
85
+ final[c] = const_cols[c]
86
+ elif c in out.columns:
87
+ final[c] = out[c]
88
+
89
+ dtypes = bundle.get("original_dtypes") or {}
90
+ for c, dts in dtypes.items():
91
+ if c not in final.columns:
92
+ continue
93
+ try:
94
+ if "int" in dts:
95
+ final[c] = pd.to_numeric(final[c], errors="coerce").astype("Int64")
96
+ elif "float" in dts:
97
+ final[c] = pd.to_numeric(final[c], errors="coerce")
98
+ except Exception:
99
+ pass
100
+
101
+ if len(final) != num_rows:
102
+ final = final.iloc[:num_rows].copy()
103
+ final = final.reset_index(drop=True)
104
+ final.to_csv("/work/output-SpecializedModels/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet-c19-32759-20260422_192846.csv", index=False)
105
+ print(f"[BayesNet] Generated {len(final)} rows (requested {num_rows}) -> /work/output-SpecializedModels/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet-c19-32759-20260422_192846.csv")
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/_bayesnet_train.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import json
3
+ import pickle
4
+ import subprocess
5
+ import sys
6
+ import warnings
7
+
8
+ import numpy as np
9
+ import pandas as pd
10
+ from pgmpy.estimators import TreeSearch
11
+ from pgmpy.models import DiscreteBayesianNetwork
12
+ warnings.filterwarnings("ignore", category=FutureWarning)
13
+
14
+ def _ensure_cloudpickle():
15
+ try:
16
+ import cloudpickle # noqa: F401
17
+ except ModuleNotFoundError:
18
+ subprocess.check_call(
19
+ [sys.executable, "-m", "pip", "install", "--quiet", "cloudpickle"],
20
+ )
21
+
22
+ _ensure_cloudpickle()
23
+
24
+ with open("/work/output-SpecializedModels/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_coltypes.json", "r", encoding="utf-8") as _f:
25
+ colmeta = json.load(_f)
26
+ integer_columns = set(colmeta.get("integer_columns") or [])
27
+
28
+ df = pd.read_csv("/work/output-SpecializedModels/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/train.csv")
29
+ df = df.dropna(axis=1, how="all")
30
+ full_column_order = list(df.columns)
31
+
32
+ const_cols = {}
33
+ for col in list(df.columns):
34
+ if df[col].nunique(dropna=True) <= 1:
35
+ const_cols[col] = df[col].iloc[0] if len(df) > 0 else None
36
+ df = df.drop(columns=[col])
37
+ print(f"[BayesNet] Dropped zero-variance column '{col}'")
38
+
39
+ const_path = "/work/output-SpecializedModels/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_model.pkl".replace("bayesnet_model.pkl", "const_cols.json")
40
+ with open(const_path, "w", encoding="utf-8") as _f:
41
+ json.dump({k: str(v) for k, v in const_cols.items()}, _f)
42
+
43
+ inverse = {"categorical": {}, "continuous": {}}
44
+ enc = pd.DataFrame(index=df.index)
45
+ _n_samples = len(df)
46
+ _n_plan = sum(
47
+ 1 for e in colmeta["columns"] if str(e.get("name", "")) in df.columns
48
+ )
49
+ max_bins = 10
50
+ max_cat_levels = 256
51
+ if _n_plan > 35 or _n_samples > 200000:
52
+ max_bins = 5
53
+ max_cat_levels = 64
54
+ if _n_plan > 55:
55
+ max_bins = 4
56
+ max_cat_levels = 32
57
+ print(
58
+ f"[BayesNet] max_bins={max_bins}, max_cat_levels={max_cat_levels} "
59
+ f"(cols_in_df={_n_plan}, rows={_n_samples})"
60
+ )
61
+
62
+ for entry in colmeta["columns"]:
63
+ name = entry["name"]
64
+ if name not in df.columns:
65
+ continue
66
+ kind = entry["type"]
67
+ s = df[name]
68
+ if kind == "categorical":
69
+ s2 = s.astype(str).fillna("__NA__")
70
+ counts = s2.value_counts(dropna=False)
71
+ if len(counts) > max_cat_levels:
72
+ keep = set(counts.index[: max_cat_levels - 1].tolist())
73
+ s2 = s2.map(lambda x: x if x in keep else "__OTHER__")
74
+ uniques = sorted(s2.dropna().unique(), key=lambda x: str(x))
75
+ mapping = {str(v): i for i, v in enumerate(uniques)}
76
+ inverse["categorical"][name] = [uniques[i] for i in range(len(uniques))]
77
+ enc[name] = s2.map(lambda x, m=mapping: m.get(str(x), 0)).astype(int)
78
+ else:
79
+ s_num = pd.to_numeric(s, errors="coerce")
80
+ nu = int(s_num.nunique(dropna=True))
81
+ q = min(max_bins, max(2, nu))
82
+ if nu < 2:
83
+ enc[name] = np.zeros(len(s_num), dtype=int)
84
+ lo, hi = float(s_num.min()), float(s_num.max())
85
+ inverse["continuous"][name] = [lo, hi]
86
+ else:
87
+ try:
88
+ _, bins = pd.qcut(
89
+ s_num, q=q, retbins=True, duplicates="drop"
90
+ )
91
+ except Exception:
92
+ med = float(s_num.median())
93
+ s2 = s_num.fillna(med)
94
+ _, bins = pd.qcut(
95
+ s2, q=min(q, 3), retbins=True, duplicates="drop"
96
+ )
97
+ bins = np.asarray(bins, dtype=float)
98
+ lab = pd.cut(
99
+ s_num, bins=bins, labels=False, include_lowest=True
100
+ )
101
+ enc[name] = lab.fillna(0).astype(int)
102
+ inverse["continuous"][name] = bins.tolist()
103
+
104
+ print(f"[BayesNet] Training on {len(enc)} rows, {len(enc.columns)} cols (encoded)")
105
+
106
+ enc_struct = enc
107
+ if len(enc) > 25000:
108
+ enc_struct = enc.sample(n=25000, random_state=0, replace=False)
109
+ print(f"[BayesNet] TreeSearch on {len(enc_struct)} rows (subsample; full n={len(enc)})")
110
+ dag = TreeSearch(enc_struct).estimate(show_progress=False)
111
+ for col in enc.columns:
112
+ if col not in dag.nodes():
113
+ dag.add_node(col)
114
+ print(f"[BayesNet] Added isolated node to DAG: {col}")
115
+ network = DiscreteBayesianNetwork(dag)
116
+ enc_fit = enc
117
+ if len(enc) > 120000:
118
+ enc_fit = enc.sample(n=120000, random_state=1, replace=False)
119
+ print(f"[BayesNet] fit() on {len(enc_fit)} rows (full n={len(enc)})")
120
+ network.fit(enc_fit)
121
+
122
+ bundle = {
123
+ "network": network,
124
+ "inverse": inverse,
125
+ "column_order": list(enc.columns),
126
+ "full_column_order": full_column_order,
127
+ "integer_columns": list(integer_columns),
128
+ "original_dtypes": {c: str(df[c].dtype) for c in enc.columns},
129
+ "const_cols": const_cols,
130
+ }
131
+ with open("/work/output-SpecializedModels/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_model.pkl", "wb") as _f:
132
+ pickle.dump(bundle, _f)
133
+ print(f"[BayesNet] Model saved -> /work/output-SpecializedModels/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_model.pkl")
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet-c19-32759-20260422_192846.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e8ef5e493abf71a0807c66d7c508fba12cdd8b65e5924629fcf5633206328d7a
3
+ size 12529183
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_coltypes.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:824d8a2b5a901837769991f65ba261818dbe2589a985464485da14f9cf893cf2
3
+ size 1162
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:133949fdd908b50d09a312ea1d975cc6d1765d7b2952a8e1b49081067745d7a6
3
+ size 4111174
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/const_cols.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
3
+ size 2
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/gen_20260422_192846.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d2e25e055b57077adda4068181bcbc6427aef056a6a4d7e706dc283b5e0d6cd
3
+ size 3393
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/input_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:abeff74152f802f0e06e5cdb720e6e285127a1e97b8f15c44f8c9e09aad598e8
3
+ size 1366
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/normalized_schema_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29277905718aadff6392f1a493cc90a009209da285eb3c9cfaa6ed315532ed07
3
+ size 15890
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/public_gate_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f3b9879993ec6898672e12c529e80204564945d19d90073329035241094707d
3
+ size 925
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/staged_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b2a47f9b86e807eff9ffdd5600ab56d33c7a1a07c42242e2ec98cf8a9e3d4dc
3
+ size 16691
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/runtime_result.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e42b48b3e99174486fc3206b687cc5f9ec1200712cfd8e2b4a6b51f31ebda72
3
+ size 613
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/adapter_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2152fcecf5bb7b7ab05b8615971ee42ab85b7a7657794af22a14c1895cce569f
3
+ size 321
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/adapter_transforms_applied.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945
3
+ size 2
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/model_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0179df816489bddd2c4928fb62454f583e3e3e5c849839ebfff1f45b2a29fa0a
3
+ size 16888
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/staged_features.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a57a0c3c2a45c85e74d4496ad733ad7f30b2615f97be5155850895fee1727948
3
+ size 1564
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd9c98343a92c7b1afe63b402f07b9a55013adbfcc60ec1e17d5e026385eeec8
3
+ size 6304860
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/train.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:092346325db7f445db2c00d2f5dd9a8397ecc33eaba7b2b14d9d48d92659fcfc
3
+ size 51459027
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/val.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69c75639e81916d3b4f2a28db38d7e15c78e442748aa5bf9fed2eb3784912a70
3
+ size 6331589
syntheticSuccess/c19/bayesnet/bayesnet-c19-20260422_192809/train_20260422_192819.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c3aaf58a023b18cf28e974d70699520a2eeb02768c612cbdf6154f76b14f372
3
+ size 3532
syntheticSuccess/c19/ctgan/ctgan-c19-20260422_031259/_ctgan_generate.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ sys.path.insert(0, "/work")
3
+ from src.SpecificModels.ctgan_rdt_inverse_fix import apply_ctgan_inverse_fix
4
+ apply_ctgan_inverse_fix()
5
+ import pandas as pd
6
+ from ctgan.synthesizers.ctgan import CTGAN
7
+ model = CTGAN.load("/work/output-SpecializedModels/c19/ctgan/ctgan-c19-20260422_031259/models_300epochs/ctgan_300epochs.pt")
8
+ total = 32759
9
+ chunk = min(50000, total) if total > 50000 else total
10
+ parts = []
11
+ left = total
12
+ while left > 0:
13
+ take = min(chunk, left)
14
+ parts.append(model.sample(take))
15
+ left -= take
16
+ sampled = pd.concat(parts, ignore_index=True) if len(parts) > 1 else parts[0]
17
+ sampled.to_csv("/work/output-SpecializedModels/c19/ctgan/ctgan-c19-20260422_031259/ctgan-c19-32759-20260422_120804.csv", index=False)
18
+ print("[CTGAN] Generated", total, "rows in", len(parts), "chunks ->", "/work/output-SpecializedModels/c19/ctgan/ctgan-c19-20260422_031259/ctgan-c19-32759-20260422_120804.csv")
syntheticSuccess/c19/tabpfgen/tabpfgen-c19-20260422_200215/_tabpfgen_generate.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import json
4
+ from tabpfgen import TabPFGen
5
+
6
+ df = pd.read_csv("/work/output-SpecializedModels/c19/tabpfgen/tabpfgen-c19-20260422_200215/staged/public/train.csv")
7
+ target_col = "category_id"
8
+
9
+ feature_cols = [c for c in df.columns if c != target_col]
10
+
11
+ # --- Label-encode categorical / object columns ---
12
+ cat_encodings = {} # col -> list of unique values (index = code)
13
+ for col in feature_cols:
14
+ if df[col].dtype == object or str(df[col].dtype) == 'category':
15
+ cats = sorted(df[col].dropna().unique().tolist(), key=str)
16
+ cat_map = {v: i for i, v in enumerate(cats)}
17
+ df[col] = df[col].map(cat_map).astype(float)
18
+ cat_encodings[col] = cats
19
+ print(f"[TabPFGen] Label-encoded '{col}' ({len(cats)} categories)")
20
+
21
+ # Encode target if categorical
22
+ target_cats = None
23
+ if df[target_col].dtype == object or str(df[target_col].dtype) == 'category':
24
+ cats = sorted(df[target_col].dropna().unique().tolist(), key=str)
25
+ t_map = {v: i for i, v in enumerate(cats)}
26
+ df[target_col] = df[target_col].map(t_map).astype(float)
27
+ target_cats = cats
28
+ print(f"[TabPFGen] Label-encoded target '{target_col}' ({len(cats)} categories)")
29
+
30
+ X = df[feature_cols].values.astype(np.float32)
31
+ y = df[target_col].values
32
+ target_n = int(32759)
33
+
34
+ # Handle NaN
35
+ for i in range(X.shape[1]):
36
+ col_vals = X[:, i]
37
+ mask = np.isnan(col_vals)
38
+ if mask.any():
39
+ mean_val = np.nanmean(col_vals)
40
+ X[mask, i] = mean_val if not np.isnan(mean_val) else 0.0
41
+
42
+ gen = TabPFGen(
43
+ n_sgld_steps=1000,
44
+ sgld_step_size=0.01,
45
+ sgld_noise_scale=0.01,
46
+ device="auto",
47
+ )
48
+
49
+ print(f"[TabPFGen] Generating {target_n} rows via generate_regression")
50
+ X_syn, y_syn = gen.generate_regression(X, y, n_samples=target_n)
51
+
52
+ syn_df = pd.DataFrame(X_syn, columns=feature_cols)
53
+ syn_df[target_col] = y_syn
54
+
55
+ # --- Inverse label-encoding for categorical columns ---
56
+ for col, cats in cat_encodings.items():
57
+ # Round to nearest integer index, clamp to valid range
58
+ codes = np.round(syn_df[col].values).astype(int)
59
+ codes = np.clip(codes, 0, len(cats) - 1)
60
+ syn_df[col] = [cats[c] for c in codes]
61
+
62
+ if target_cats is not None:
63
+ codes = np.round(syn_df[target_col].values).astype(int)
64
+ codes = np.clip(codes, 0, len(target_cats) - 1)
65
+ syn_df[target_col] = [target_cats[c] for c in codes]
66
+
67
+ # Ensure output row count is strictly aligned with target_n.
68
+ if len(syn_df) > target_n:
69
+ print(f"[TabPFGen] Trimming rows: {len(syn_df)} -> {target_n}")
70
+ syn_df = syn_df.iloc[:target_n].copy()
71
+ elif len(syn_df) < target_n:
72
+ deficit = target_n - len(syn_df)
73
+ print(f"[TabPFGen] Padding rows: {len(syn_df)} -> {target_n} (deficit={deficit})")
74
+ if len(syn_df) > 0:
75
+ extra = syn_df.sample(n=deficit, replace=True, random_state=42)
76
+ syn_df = pd.concat([syn_df.reset_index(drop=True), extra.reset_index(drop=True)], ignore_index=True)
77
+ else:
78
+ # Defensive fallback: if generator returns empty, bootstrap from training rows.
79
+ syn_df = df[feature_cols + [target_col]].sample(
80
+ n=target_n, replace=True, random_state=42
81
+ ).reset_index(drop=True)
82
+
83
+ syn_df = syn_df[list(df.columns)]
84
+ if len(syn_df) != target_n:
85
+ raise RuntimeError(f"[TabPFGen] Row alignment failed: got {len(syn_df)}, expected {target_n}")
86
+ syn_df.to_csv("/work/output-SpecializedModels/c19/tabpfgen/tabpfgen-c19-20260422_200215/tabpfgen-c19-32759-20260422_200228.csv", index=False)
87
+ print(f"[TabPFGen] Saved {len(syn_df)} rows -> /work/output-SpecializedModels/c19/tabpfgen/tabpfgen-c19-20260422_200215/tabpfgen-c19-32759-20260422_200228.csv")
syntheticSuccess/c19/tabpfgen/tabpfgen-c19-20260422_200215/staged/public/train.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:092346325db7f445db2c00d2f5dd9a8397ecc33eaba7b2b14d9d48d92659fcfc
3
+ size 51459027
syntheticSuccess/c19/tabpfgen/tabpfgen-c19-20260422_200215/tabpfgen-c19-32759-20260422_200228.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0767b1943abbb94f75c60b5e828e4130791b09dead498afbc3bc4cc1697abbc
3
+ size 53657638
syntheticSuccess/c19/tabsyn/tabsyn-c19-20260426_203054/_tabsyn_sample.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, sys, subprocess
2
+
3
+ work_dir = "/work/output-SpecializedModels/c19/tabsyn/tabsyn-c19-20260426_203054"
4
+ dataname = "tabsyn_c19"
5
+ output_csv = "/work/output-SpecializedModels/c19/tabsyn/tabsyn-c19-20260426_203054/tabsyn-c19-32759-20260426_205855.csv"
6
+ tabsyn_root = "/workspace/tabsyn"
7
+
8
+ assert os.path.exists(tabsyn_root), f"TabSyn source not mounted: {tabsyn_root}"
9
+
10
+ old = os.environ.get("PYTHONPATH", "")
11
+ os.environ["PYTHONPATH"] = tabsyn_root + (os.pathsep + old if old else "")
12
+ sys.path.insert(0, tabsyn_root)
13
+
14
+ os.chdir(tabsyn_root)
15
+
16
+ # Ensure data symlink exists
17
+ data_link = os.path.join(tabsyn_root, "data", dataname)
18
+ data_src = os.path.join(work_dir, "data", dataname)
19
+ os.makedirs(os.path.join(tabsyn_root, "data"), exist_ok=True)
20
+ if os.path.exists(data_link):
21
+ os.remove(data_link)
22
+ os.symlink(data_src, data_link)
23
+
24
+ print(f"[TabSyn] Sampling 32759 rows")
25
+ env = os.environ.copy()
26
+ env.setdefault("TABSYN_RESUME", "1")
27
+ ret = subprocess.run(
28
+ [sys.executable, "main.py",
29
+ "--dataname", dataname,
30
+ "--mode", "sample",
31
+ "--method", "tabsyn",
32
+ "--gpu", "0",
33
+ "--save_path", output_csv],
34
+ cwd=tabsyn_root,
35
+ env=env
36
+ )
37
+ if ret.returncode != 0:
38
+ sys.exit(ret.returncode)
39
+ print(f"[TabSyn] Saved -> {output_csv}")
syntheticSuccess/c19/tabsyn/tabsyn-c19-20260426_203054/_tabsyn_train.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, sys, subprocess
2
+
3
+ work_dir = "/work/output-SpecializedModels/c19/tabsyn/tabsyn-c19-20260426_203054"
4
+ dataname = "tabsyn_c19"
5
+ tabsyn_root = "/workspace/tabsyn"
6
+
7
+ assert os.path.exists(tabsyn_root), f"TabSyn source not mounted: {tabsyn_root}"
8
+
9
+ old = os.environ.get("PYTHONPATH", "")
10
+ os.environ["PYTHONPATH"] = tabsyn_root + (os.pathsep + old if old else "")
11
+ sys.path.insert(0, tabsyn_root)
12
+
13
+ os.chdir(tabsyn_root)
14
+
15
+ # Symlink data dir into TabSyn data/
16
+ data_link = os.path.join(tabsyn_root, "data", dataname)
17
+ data_src = os.path.join(work_dir, "data", dataname)
18
+ os.makedirs(os.path.join(tabsyn_root, "data"), exist_ok=True)
19
+ if os.path.exists(data_link):
20
+ os.remove(data_link)
21
+ os.symlink(data_src, data_link)
22
+
23
+ env = os.environ.copy()
24
+ env.setdefault("TABSYN_RESUME", "1")
25
+ env.setdefault("TABSYN_VAE_BATCH_SIZE", "1024")
26
+ _te = 1000
27
+ if _te is not None:
28
+ env["TABSYN_VAE_EPOCHS"] = str(_te)
29
+ env["TABSYN_DIFFUSION_MAX_EPOCHS"] = str(max(_te + 1, 2))
30
+
31
+ # Data preprocessing is done on the host side (_prepare_data_dir)
32
+ # which creates .npy files, train/test CSVs, and info.json
33
+
34
+ # Step 1: Train VAE (produces latent embeddings)
35
+ print(f"[TabSyn] Step 1/2: Training VAE in {tabsyn_root}, dataname={dataname}")
36
+ ret = subprocess.run(
37
+ [sys.executable, "main.py",
38
+ "--dataname", dataname,
39
+ "--mode", "train",
40
+ "--method", "vae",
41
+ "--gpu", "0"],
42
+ cwd=tabsyn_root,
43
+ env=env
44
+ )
45
+ if ret.returncode != 0:
46
+ print("[TabSyn] VAE training failed")
47
+ sys.exit(ret.returncode)
48
+
49
+ # Step 2: Train diffusion model on latent space
50
+ print(f"[TabSyn] Step 2/2: Training diffusion model")
51
+ ret = subprocess.run(
52
+ [sys.executable, "main.py",
53
+ "--dataname", dataname,
54
+ "--mode", "train",
55
+ "--method", "tabsyn",
56
+ "--gpu", "0"],
57
+ cwd=tabsyn_root,
58
+ env=env
59
+ )
60
+ if ret.returncode != 0:
61
+ print("[TabSyn] Diffusion training failed")
62
+ sys.exit(ret.returncode)
63
+ print("[TabSyn] Training complete (VAE + Diffusion)")
syntheticSuccess/c19/tabsyn/tabsyn-c19-20260426_203054/staged/public/train.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:092346325db7f445db2c00d2f5dd9a8397ecc33eaba7b2b14d9d48d92659fcfc
3
+ size 51459027
syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/_tvae_generate.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ sys.path.insert(0, "/work")
3
+ from src.SpecificModels.ctgan_rdt_inverse_fix import apply_ctgan_inverse_fix
4
+ apply_ctgan_inverse_fix()
5
+ import pandas as pd
6
+ from ctgan.synthesizers.tvae import TVAE
7
+ model = TVAE.load("/work/output-SpecializedModels/c19/tvae/tvae-c19-20260328_052612/models_300epochs/tvae_300epochs.pt")
8
+ total = 32759
9
+ chunk = min(50000, total) if total > 50000 else total
10
+ parts = []
11
+ left = total
12
+ while left > 0:
13
+ take = min(chunk, left)
14
+ parts.append(model.sample(take))
15
+ left -= take
16
+ samples = pd.concat(parts, ignore_index=True) if len(parts) > 1 else parts[0]
17
+ samples.to_csv("/work/output-SpecializedModels/c19/tvae/tvae-c19-20260328_052612/tvae-c19-32759-20260420_023428.csv", index=False)
18
+ print(f"[TVAE] Generated {total} rows (chunks={len(parts)}) -> /work/output-SpecializedModels/c19/tvae/tvae-c19-20260328_052612/tvae-c19-32759-20260420_023428.csv")
syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/_tvae_train.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json, sys
2
+ import pandas as pd
3
+ from ctgan.data import read_csv
4
+ from ctgan.synthesizers.tvae import TVAE
5
+
6
+ csv_path = "/work/output-SpecializedModels/c19/tvae/tvae-c19-20260328_052612/staged/public/train.csv"
7
+ meta_path = "/work/output-SpecializedModels/c19/tvae/tvae-c19-20260328_052612/tvae_metadata.json"
8
+ save_path = "/work/output-SpecializedModels/c19/tvae/tvae-c19-20260328_052612/models_300epochs/tvae_300epochs.pt"
9
+ epochs = 300
10
+
11
+ data, discrete_columns = read_csv(csv_path, meta_path, header=True, discrete=None)
12
+ print(f"[TVAE] Training on {len(data)} rows, {len(data.columns)} cols, epochs={epochs}")
13
+ model = TVAE(epochs=epochs, batch_size=500)
14
+ model.fit(data, discrete_columns)
15
+ model.save(save_path)
16
+ print(f"[TVAE] Model saved -> {save_path}")
syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/gen_20260419_072541.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:edab0065a1b970f7074bf3ac9b73ffb31b289e6253ba6dcabd9cc162483516ba
3
+ size 533
syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/gen_20260420_023428.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:268789f568e0ee186be3f3bb4123e9556ee6c96de4cb9bfb625d15e767726951
3
+ size 544
syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/input_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3773432f9af837271b2e1ed3115390812b01b0c38bbaa6f15c25e0ef3ba2591e
3
+ size 1362
syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/runtime_result.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01562a12fc1c95957a1540ed5b2c09e0e3eb46a121e22c178608e425877cf09d
3
+ size 442
syntheticSuccess/c19/tvae/tvae-c19-20260328_052612/tvae_metadata.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:761007e5936a02e408256fa21d2e8db8b85fc746a47d8b03a9e4bc007150ec0e
3
+ size 1137