Add files using upload-large-folder tool
Browse files- syntheticSuccess/m2/arf/arf-m2-20260321_061123/_arf_generate.py +6 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/_arf_train.py +19 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/arf-m2-1000-20260321_063147.csv +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/arf-m2-46873-20260330_065607.csv +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/arf_model.pkl +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/gen_20260321_063147.log +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/gen_20260330_065607.log +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/input_snapshot.json +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/public_gate/normalized_schema_snapshot.json +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/public_gate/public_gate_report.json +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/public_gate/staged_input_manifest.json +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/runtime_result.json +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/arf/adapter_report.json +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/arf/adapter_transforms_applied.json +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/arf/model_input_manifest.json +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/public/staged_features.json +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/public/test.csv +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/public/train.csv +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/public/val.csv +3 -0
- syntheticSuccess/m2/arf/arf-m2-20260321_061123/train_20260321_061126.log +3 -0
- syntheticSuccess/m2/bayesnet/bayesnet-m2-20260422_060152/_bayesnet_generate.py +104 -0
- syntheticSuccess/m2/bayesnet/bayesnet-m2-20260422_060152/_bayesnet_train.py +118 -0
- syntheticSuccess/m2/bayesnet/bayesnet-m2-20260422_060152/bayesnet-m2-46873-20260422_060321.csv +3 -0
- syntheticSuccess/m2/bayesnet/bayesnet-m2-20260422_060152/bayesnet_model.pkl +3 -0
- syntheticSuccess/m2/ctgan/ctgan-m2-20260322_064651/ctgan-m2-1000-20260322_205352.csv +3 -0
- syntheticSuccess/m2/ctgan/ctgan-m2-20260322_064651/gen_20260322_205352.log +0 -0
- syntheticSuccess/m2/ctgan/ctgan-m2-20260322_064651/gen_20260330_065545.log +0 -0
- syntheticSuccess/m2/tabddpm/tabddpm-m2-20260424_033725/_tabddpm_sample.py +67 -0
- syntheticSuccess/m2/tabddpm/tabddpm-m2-20260424_033725/_tabddpm_train.py +32 -0
- syntheticSuccess/m2/tabpfgen/tabpfgen-m2-20260422_211345/_tabpfgen_generate.py +87 -0
- syntheticSuccess/m2/tabsyn/tabsyn-m2-20260421_023648/_tabsyn_sample.py +39 -0
- syntheticSuccess/m2/tabsyn/tabsyn-m2-20260421_023648/_tabsyn_train.py +62 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/_tvae_generate.py +5 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/_tvae_train.py +16 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/gen_20260321_065656.log +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/gen_20260330_065546.log +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/input_snapshot.json +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/models_300epochs/train_20260321_062140.log +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/public_gate/normalized_schema_snapshot.json +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/public_gate/public_gate_report.json +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/public_gate/staged_input_manifest.json +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/runtime_result.json +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/public/staged_features.json +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/public/test.csv +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/public/val.csv +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/tvae/adapter_report.json +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/tvae/adapter_transforms_applied.json +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/tvae/model_input_manifest.json +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/tvae-m2-1000-20260321_065656.csv +3 -0
- syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/tvae_metadata.json +3 -0
syntheticSuccess/m2/arf/arf-m2-20260321_061123/_arf_generate.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pickle
|
| 2 |
+
with open("/work/output-SpecializedModels/m2/arf/arf-m2-20260321_061123/arf_model.pkl", "rb") as f:
|
| 3 |
+
model = pickle.load(f)
|
| 4 |
+
syn = model.forge(n=46873)
|
| 5 |
+
syn.to_csv("/work/output-SpecializedModels/m2/arf/arf-m2-20260321_061123/arf-m2-46873-20260330_065607.csv", index=False)
|
| 6 |
+
print(f"[ARF] Generated 46873 rows -> /work/output-SpecializedModels/m2/arf/arf-m2-20260321_061123/arf-m2-46873-20260330_065607.csv")
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/_arf_train.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pickle
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from arfpy import arf
|
| 4 |
+
|
| 5 |
+
df = pd.read_csv("/work/output-SpecializedModels/m2/arf/arf-m2-20260321_061123/staged/public/train.csv")
|
| 6 |
+
df = df.dropna(axis=1, how="all")
|
| 7 |
+
print(f"[ARF] Training on {len(df)} rows, {len(df.columns)} cols")
|
| 8 |
+
|
| 9 |
+
model = arf.arf(x=df)
|
| 10 |
+
if hasattr(model, "fit"):
|
| 11 |
+
model.fit()
|
| 12 |
+
elif hasattr(model, "forde"):
|
| 13 |
+
model.forde()
|
| 14 |
+
else:
|
| 15 |
+
raise RuntimeError("arfpy API: no fit() / forde()")
|
| 16 |
+
|
| 17 |
+
with open("/work/output-SpecializedModels/m2/arf/arf-m2-20260321_061123/arf_model.pkl", "wb") as f:
|
| 18 |
+
pickle.dump(model, f)
|
| 19 |
+
print(f"[ARF] Model saved -> /work/output-SpecializedModels/m2/arf/arf-m2-20260321_061123/arf_model.pkl")
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/arf-m2-1000-20260321_063147.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8aac9709b05afb737aa0b0de5debed08a3efc8216b8714503cfdf091cdd52196
|
| 3 |
+
size 305240
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/arf-m2-46873-20260330_065607.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:98d136794c40814aee885130892c3d5969ba5d3e83b42d84d9fd22a019aafccb
|
| 3 |
+
size 14334332
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/arf_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0785c85bffc0f57de32c71bf3b795565334ec8a183d95a72700bd8b3e41b93c3
|
| 3 |
+
size 228900034
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/gen_20260321_063147.log
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f2acf6d8260bf6b0bf023f9a2089b9d3afbbada9026ca40508d322f791e8fb7e
|
| 3 |
+
size 9286
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/gen_20260330_065607.log
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d1e0027924b929c30c4a307d6fb09391b03d5bc127af183a673267083f03faf2
|
| 3 |
+
size 9288
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/input_snapshot.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:993e3162b2a2efc899823268d21c5615abc5350c3451dccbb85a169234d908a8
|
| 3 |
+
size 1350
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/public_gate/normalized_schema_snapshot.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0fb5052492ee861d52ad1b492c5d1a2dedbf06d194d8aeafb51953de9534b028
|
| 3 |
+
size 19592
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/public_gate/public_gate_report.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b79ab92f54ef5b314717b7374a9cda8d74cce8a43ed3a393dd006286bec88825
|
| 3 |
+
size 936
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/public_gate/staged_input_manifest.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:37ca94af82f8441a0bbec0e8e78e304f8f447ae1195b1aa7cb244e330938c1f4
|
| 3 |
+
size 20333
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/runtime_result.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e00fa5148904c2d610774cb5e3c0d03803d8200c79b876e4f8825e49e29bcace
|
| 3 |
+
size 432
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/arf/adapter_report.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:70ac2823c127ca7644ff08c7a4ee891d4e5b42963800647a6a70958af2f367d2
|
| 3 |
+
size 304
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/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/m2/arf/arf-m2-20260321_061123/staged/arf/model_input_manifest.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1274984f75d3aaa974a1995657210f04bf7c2b278ba151a7f03b034612fe1c60
|
| 3 |
+
size 20513
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/public/staged_features.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5a1cb02abaf420d49bbf426e8d98820cac1ee0712808f84e1add5f989702bfb5
|
| 3 |
+
size 4350
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/public/test.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3321107cd4eb2ecfc26606c36779c9c019cd8819078c2c782db9638870417ffb
|
| 3 |
+
size 1383062
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/public/train.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3466b221382fe7e20ef33c4b5b6eead0702d0c63fdea6706e18b9d1858a9066d
|
| 3 |
+
size 11072631
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/staged/public/val.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f244b4756876af1cb6945def77c203f9ed6623a2356b198441f6acc066f3ab5d
|
| 3 |
+
size 1384259
|
syntheticSuccess/m2/arf/arf-m2-20260321_061123/train_20260321_061126.log
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b7850ed254d6d9af67de0e7bf4bbc09d3abd5d84f4744d5f417716b1ee727b61
|
| 3 |
+
size 334
|
syntheticSuccess/m2/bayesnet/bayesnet-m2-20260422_060152/_bayesnet_generate.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/m2/bayesnet/bayesnet-m2-20260422_060152/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(46873)
|
| 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.to_csv("/work/output-SpecializedModels/m2/bayesnet/bayesnet-m2-20260422_060152/bayesnet-m2-46873-20260422_060321.csv", index=False)
|
| 104 |
+
print(f"[BayesNet] Generated {len(final)} rows (requested {num_rows}) -> /work/output-SpecializedModels/m2/bayesnet/bayesnet-m2-20260422_060152/bayesnet-m2-46873-20260422_060321.csv")
|
syntheticSuccess/m2/bayesnet/bayesnet-m2-20260422_060152/_bayesnet_train.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/m2/bayesnet/bayesnet-m2-20260422_060152/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/m2/bayesnet/bayesnet-m2-20260422_060152/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/m2/bayesnet/bayesnet-m2-20260422_060152/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 |
+
if _n_plan > 35 or _n_samples > 200000:
|
| 51 |
+
max_bins = 5
|
| 52 |
+
if _n_plan > 55:
|
| 53 |
+
max_bins = 4
|
| 54 |
+
print(f"[BayesNet] max_bins={max_bins} (cols_in_df={_n_plan}, rows={_n_samples})")
|
| 55 |
+
|
| 56 |
+
for entry in colmeta["columns"]:
|
| 57 |
+
name = entry["name"]
|
| 58 |
+
if name not in df.columns:
|
| 59 |
+
continue
|
| 60 |
+
kind = entry["type"]
|
| 61 |
+
s = df[name]
|
| 62 |
+
if kind == "categorical":
|
| 63 |
+
uniques = sorted(s.dropna().unique(), key=lambda x: str(x))
|
| 64 |
+
mapping = {str(v): i for i, v in enumerate(uniques)}
|
| 65 |
+
inverse["categorical"][name] = [uniques[i] for i in range(len(uniques))]
|
| 66 |
+
enc[name] = s.map(lambda x, m=mapping: m.get(str(x), 0)).astype(int)
|
| 67 |
+
else:
|
| 68 |
+
s_num = pd.to_numeric(s, errors="coerce")
|
| 69 |
+
nu = int(s_num.nunique(dropna=True))
|
| 70 |
+
q = min(max_bins, max(2, nu))
|
| 71 |
+
if nu < 2:
|
| 72 |
+
enc[name] = np.zeros(len(s_num), dtype=int)
|
| 73 |
+
lo, hi = float(s_num.min()), float(s_num.max())
|
| 74 |
+
inverse["continuous"][name] = [lo, hi]
|
| 75 |
+
else:
|
| 76 |
+
try:
|
| 77 |
+
_, bins = pd.qcut(
|
| 78 |
+
s_num, q=q, retbins=True, duplicates="drop"
|
| 79 |
+
)
|
| 80 |
+
except Exception:
|
| 81 |
+
med = float(s_num.median())
|
| 82 |
+
s2 = s_num.fillna(med)
|
| 83 |
+
_, bins = pd.qcut(
|
| 84 |
+
s2, q=min(q, 3), retbins=True, duplicates="drop"
|
| 85 |
+
)
|
| 86 |
+
bins = np.asarray(bins, dtype=float)
|
| 87 |
+
lab = pd.cut(
|
| 88 |
+
s_num, bins=bins, labels=False, include_lowest=True
|
| 89 |
+
)
|
| 90 |
+
enc[name] = lab.fillna(0).astype(int)
|
| 91 |
+
inverse["continuous"][name] = bins.tolist()
|
| 92 |
+
|
| 93 |
+
print(f"[BayesNet] Training on {len(enc)} rows, {len(enc.columns)} cols (encoded)")
|
| 94 |
+
|
| 95 |
+
enc_struct = enc
|
| 96 |
+
if len(enc) > 25000:
|
| 97 |
+
enc_struct = enc.sample(n=25000, random_state=0, replace=False)
|
| 98 |
+
print(f"[BayesNet] TreeSearch on {len(enc_struct)} rows (subsample; full n={len(enc)})")
|
| 99 |
+
dag = TreeSearch(enc_struct).estimate(show_progress=False)
|
| 100 |
+
for col in enc.columns:
|
| 101 |
+
if col not in dag.nodes():
|
| 102 |
+
dag.add_node(col)
|
| 103 |
+
print(f"[BayesNet] Added isolated node to DAG: {col}")
|
| 104 |
+
network = DiscreteBayesianNetwork(dag)
|
| 105 |
+
network.fit(enc)
|
| 106 |
+
|
| 107 |
+
bundle = {
|
| 108 |
+
"network": network,
|
| 109 |
+
"inverse": inverse,
|
| 110 |
+
"column_order": list(enc.columns),
|
| 111 |
+
"full_column_order": full_column_order,
|
| 112 |
+
"integer_columns": list(integer_columns),
|
| 113 |
+
"original_dtypes": {c: str(df[c].dtype) for c in enc.columns},
|
| 114 |
+
"const_cols": const_cols,
|
| 115 |
+
}
|
| 116 |
+
with open("/work/output-SpecializedModels/m2/bayesnet/bayesnet-m2-20260422_060152/bayesnet_model.pkl", "wb") as _f:
|
| 117 |
+
pickle.dump(bundle, _f)
|
| 118 |
+
print(f"[BayesNet] Model saved -> /work/output-SpecializedModels/m2/bayesnet/bayesnet-m2-20260422_060152/bayesnet_model.pkl")
|
syntheticSuccess/m2/bayesnet/bayesnet-m2-20260422_060152/bayesnet-m2-46873-20260422_060321.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:88d26b575a567d214214f8abf376dbb98ff19a131ea8b2b7c47e6a47e3b277ab
|
| 3 |
+
size 20307599
|
syntheticSuccess/m2/bayesnet/bayesnet-m2-20260422_060152/bayesnet_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9b35a785980bfd127e4a76430fcfd060e1e5dc4190feeb4d6d1a01be6944d23f
|
| 3 |
+
size 74031568
|
syntheticSuccess/m2/ctgan/ctgan-m2-20260322_064651/ctgan-m2-1000-20260322_205352.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cd4e49f9a3ddfa9a4499c537a3c80005d2d0a207d93d23b4733e15d828e83087
|
| 3 |
+
size 269381
|
syntheticSuccess/m2/ctgan/ctgan-m2-20260322_064651/gen_20260322_205352.log
ADDED
|
File without changes
|
syntheticSuccess/m2/ctgan/ctgan-m2-20260322_064651/gen_20260330_065545.log
ADDED
|
File without changes
|
syntheticSuccess/m2/tabddpm/tabddpm-m2-20260424_033725/_tabddpm_sample.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os, sys, subprocess, json
|
| 2 |
+
import numpy as np
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
tabddpm_root = "/workspace/tabddpm/code"
|
| 6 |
+
assert os.path.isdir(tabddpm_root), f"TabDDPM source not mounted: {tabddpm_root}"
|
| 7 |
+
env = os.environ.copy()
|
| 8 |
+
env["PYTHONPATH"] = tabddpm_root + (os.pathsep + env.get("PYTHONPATH", ""))
|
| 9 |
+
|
| 10 |
+
# Reuse the compat wrapper (patches collections.Sequence for skorch)
|
| 11 |
+
wrapper = os.path.join(tabddpm_root, "_compat_run.py")
|
| 12 |
+
if not os.path.exists(wrapper):
|
| 13 |
+
with open(wrapper, "w") as f:
|
| 14 |
+
f.write(
|
| 15 |
+
"import collections, collections.abc\n"
|
| 16 |
+
"for _a in ('Sequence','MutableSequence','MutableMapping','Mapping',"
|
| 17 |
+
"'MutableSet','Set','Callable','Iterable','Iterator'):\n"
|
| 18 |
+
" if not hasattr(collections, _a): setattr(collections, _a, getattr(collections.abc, _a, None))\n"
|
| 19 |
+
"import sys, runpy\n"
|
| 20 |
+
"sys.argv = sys.argv[1:]\n"
|
| 21 |
+
"runpy.run_path(sys.argv[0], run_name='__main__')\n"
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
print(f"[TabDDPM] Sampling 46873 rows")
|
| 25 |
+
ret = subprocess.run(
|
| 26 |
+
[sys.executable, wrapper, "scripts/pipeline.py",
|
| 27 |
+
"--config", "/work/output-SpecializedModels/m2/tabddpm/tabddpm-m2-20260424_033725/config_sample_20260424_034336.toml",
|
| 28 |
+
"--sample"],
|
| 29 |
+
cwd=tabddpm_root,
|
| 30 |
+
env=env
|
| 31 |
+
)
|
| 32 |
+
if ret.returncode != 0:
|
| 33 |
+
sys.exit(ret.returncode)
|
| 34 |
+
|
| 35 |
+
# 将 .npy 输出转为 CSV
|
| 36 |
+
work_dir = "/work/output-SpecializedModels/m2/tabddpm/tabddpm-m2-20260424_033725"
|
| 37 |
+
info_path = os.path.join(work_dir, "data", "info.json")
|
| 38 |
+
with open(info_path) as f:
|
| 39 |
+
info = json.load(f)
|
| 40 |
+
|
| 41 |
+
output_dir = os.path.join(work_dir, "output")
|
| 42 |
+
col_names = info.get("column_names", [])
|
| 43 |
+
|
| 44 |
+
parts = []
|
| 45 |
+
x_num_path = os.path.join(output_dir, "X_num_train.npy")
|
| 46 |
+
x_cat_path = os.path.join(output_dir, "X_cat_train.npy")
|
| 47 |
+
y_path = os.path.join(output_dir, "y_train.npy")
|
| 48 |
+
|
| 49 |
+
if os.path.exists(x_num_path):
|
| 50 |
+
parts.append(np.load(x_num_path, allow_pickle=True))
|
| 51 |
+
if os.path.exists(x_cat_path):
|
| 52 |
+
parts.append(np.load(x_cat_path, allow_pickle=True).astype(float))
|
| 53 |
+
if os.path.exists(y_path):
|
| 54 |
+
y = np.load(y_path, allow_pickle=True)
|
| 55 |
+
parts.append(y.reshape(-1, 1) if y.ndim == 1 else y)
|
| 56 |
+
|
| 57 |
+
if parts:
|
| 58 |
+
combined = np.concatenate(parts, axis=1)
|
| 59 |
+
if col_names and len(col_names) == combined.shape[1]:
|
| 60 |
+
df = pd.DataFrame(combined, columns=col_names)
|
| 61 |
+
else:
|
| 62 |
+
df = pd.DataFrame(combined)
|
| 63 |
+
df.to_csv("/work/output-SpecializedModels/m2/tabddpm/tabddpm-m2-20260424_033725/tabddpm-m2-46873-20260424_034336.csv", index=False)
|
| 64 |
+
print(f"[TabDDPM] Saved {len(df)} rows -> /work/output-SpecializedModels/m2/tabddpm/tabddpm-m2-20260424_033725/tabddpm-m2-46873-20260424_034336.csv")
|
| 65 |
+
else:
|
| 66 |
+
print("[TabDDPM] WARNING: No output .npy files found")
|
| 67 |
+
sys.exit(1)
|
syntheticSuccess/m2/tabddpm/tabddpm-m2-20260424_033725/_tabddpm_train.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os, sys, subprocess
|
| 2 |
+
|
| 3 |
+
tabddpm_root = "/workspace/tabddpm/code"
|
| 4 |
+
assert os.path.isdir(tabddpm_root), f"TabDDPM source not mounted: {tabddpm_root}"
|
| 5 |
+
env = os.environ.copy()
|
| 6 |
+
env["PYTHONPATH"] = tabddpm_root + (os.pathsep + env.get("PYTHONPATH", ""))
|
| 7 |
+
|
| 8 |
+
# Write a wrapper that patches collections.Sequence (removed in Python 3.10+)
|
| 9 |
+
# before running pipeline.py - needed because skorch uses old API
|
| 10 |
+
wrapper = os.path.join(tabddpm_root, "_compat_run.py")
|
| 11 |
+
with open(wrapper, "w") as f:
|
| 12 |
+
f.write(
|
| 13 |
+
"import collections, collections.abc\n"
|
| 14 |
+
"for _a in ('Sequence','MutableSequence','MutableMapping','Mapping',"
|
| 15 |
+
"'MutableSet','Set','Callable','Iterable','Iterator'):\n"
|
| 16 |
+
" if not hasattr(collections, _a): setattr(collections, _a, getattr(collections.abc, _a, None))\n"
|
| 17 |
+
"import sys, runpy\n"
|
| 18 |
+
"sys.argv = sys.argv[1:]\n"
|
| 19 |
+
"runpy.run_path(sys.argv[0], run_name='__main__')\n"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
print(f"[TabDDPM] Training, config=/work/output-SpecializedModels/m2/tabddpm/tabddpm-m2-20260424_033725/config.toml")
|
| 23 |
+
ret = subprocess.run(
|
| 24 |
+
[sys.executable, wrapper, "scripts/pipeline.py",
|
| 25 |
+
"--config", "/work/output-SpecializedModels/m2/tabddpm/tabddpm-m2-20260424_033725/config.toml",
|
| 26 |
+
"--train"],
|
| 27 |
+
cwd=tabddpm_root,
|
| 28 |
+
env=env
|
| 29 |
+
)
|
| 30 |
+
if ret.returncode != 0:
|
| 31 |
+
sys.exit(ret.returncode)
|
| 32 |
+
print("[TabDDPM] Training complete")
|
syntheticSuccess/m2/tabpfgen/tabpfgen-m2-20260422_211345/_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/m2/tabpfgen/tabpfgen-m2-20260422_211345/staged/public/train.csv")
|
| 7 |
+
target_col = "is_day_night_rear_view_mirror"
|
| 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(46873)
|
| 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_classification")
|
| 50 |
+
X_syn, y_syn = gen.generate_classification(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/m2/tabpfgen/tabpfgen-m2-20260422_211345/tabpfgen-m2-46873-20260422_211350.csv", index=False)
|
| 87 |
+
print(f"[TabPFGen] Saved {len(syn_df)} rows -> /work/output-SpecializedModels/m2/tabpfgen/tabpfgen-m2-20260422_211345/tabpfgen-m2-46873-20260422_211350.csv")
|
syntheticSuccess/m2/tabsyn/tabsyn-m2-20260421_023648/_tabsyn_sample.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os, sys, subprocess
|
| 2 |
+
|
| 3 |
+
work_dir = "/work/output-SpecializedModels/m2/tabsyn/tabsyn-m2-20260421_023648"
|
| 4 |
+
dataname = "tabsyn_m2"
|
| 5 |
+
output_csv = "/work/output-SpecializedModels/m2/tabsyn/tabsyn-m2-20260421_023648/tabsyn-m2-46873-20260421_052646.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 46873 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/m2/tabsyn/tabsyn-m2-20260421_023648/_tabsyn_train.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os, sys, subprocess
|
| 2 |
+
|
| 3 |
+
work_dir = "/work/output-SpecializedModels/m2/tabsyn/tabsyn-m2-20260421_023648"
|
| 4 |
+
dataname = "tabsyn_m2"
|
| 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 |
+
_te = None
|
| 26 |
+
if _te is not None:
|
| 27 |
+
env["TABSYN_VAE_EPOCHS"] = str(_te)
|
| 28 |
+
env["TABSYN_DIFFUSION_MAX_EPOCHS"] = str(max(_te + 1, 2))
|
| 29 |
+
|
| 30 |
+
# Data preprocessing is done on the host side (_prepare_data_dir)
|
| 31 |
+
# which creates .npy files, train/test CSVs, and info.json
|
| 32 |
+
|
| 33 |
+
# Step 1: Train VAE (produces latent embeddings)
|
| 34 |
+
print(f"[TabSyn] Step 1/2: Training VAE in {tabsyn_root}, dataname={dataname}")
|
| 35 |
+
ret = subprocess.run(
|
| 36 |
+
[sys.executable, "main.py",
|
| 37 |
+
"--dataname", dataname,
|
| 38 |
+
"--mode", "train",
|
| 39 |
+
"--method", "vae",
|
| 40 |
+
"--gpu", "0"],
|
| 41 |
+
cwd=tabsyn_root,
|
| 42 |
+
env=env
|
| 43 |
+
)
|
| 44 |
+
if ret.returncode != 0:
|
| 45 |
+
print("[TabSyn] VAE training failed")
|
| 46 |
+
sys.exit(ret.returncode)
|
| 47 |
+
|
| 48 |
+
# Step 2: Train diffusion model on latent space
|
| 49 |
+
print(f"[TabSyn] Step 2/2: Training diffusion model")
|
| 50 |
+
ret = subprocess.run(
|
| 51 |
+
[sys.executable, "main.py",
|
| 52 |
+
"--dataname", dataname,
|
| 53 |
+
"--mode", "train",
|
| 54 |
+
"--method", "tabsyn",
|
| 55 |
+
"--gpu", "0"],
|
| 56 |
+
cwd=tabsyn_root,
|
| 57 |
+
env=env
|
| 58 |
+
)
|
| 59 |
+
if ret.returncode != 0:
|
| 60 |
+
print("[TabSyn] Diffusion training failed")
|
| 61 |
+
sys.exit(ret.returncode)
|
| 62 |
+
print("[TabSyn] Training complete (VAE + Diffusion)")
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/_tvae_generate.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ctgan.synthesizers.tvae import TVAE
|
| 2 |
+
model = TVAE.load("/work/output-SpecializedModels/m2/tvae/tvae-m2-20260321_062136/models_300epochs/tvae_300epochs.pt")
|
| 3 |
+
samples = model.sample(46873)
|
| 4 |
+
samples.to_csv("/work/output-SpecializedModels/m2/tvae/tvae-m2-20260321_062136/tvae-m2-46873-20260330_065546.csv", index=False)
|
| 5 |
+
print(f"[TVAE] Generated 46873 rows -> /work/output-SpecializedModels/m2/tvae/tvae-m2-20260321_062136/tvae-m2-46873-20260330_065546.csv")
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/_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/m2/tvae/tvae-m2-20260321_062136/staged/public/train.csv"
|
| 7 |
+
meta_path = "/work/output-SpecializedModels/m2/tvae/tvae-m2-20260321_062136/tvae_metadata.json"
|
| 8 |
+
save_path = "/work/output-SpecializedModels/m2/tvae/tvae-m2-20260321_062136/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/m2/tvae/tvae-m2-20260321_062136/gen_20260321_065656.log
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ee43b2c14fea94e085a7edaa2128c8db2027649cec6216c6192e793450ef1b2b
|
| 3 |
+
size 126
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/gen_20260330_065546.log
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ce2fada8217f33c18df490ad334aba90a4e9646252b8710f21463eb3efede52c
|
| 3 |
+
size 128
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/input_snapshot.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e782cbe0fa52d11c3c107c4bb3522bd984a2cecddfde34010b13cdd8585d30e1
|
| 3 |
+
size 1351
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/models_300epochs/train_20260321_062140.log
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:01419b4e04044f55ada61dff8516957a86e2ef730491897e29768afeabf93fdc
|
| 3 |
+
size 171
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/public_gate/normalized_schema_snapshot.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0fb5052492ee861d52ad1b492c5d1a2dedbf06d194d8aeafb51953de9534b028
|
| 3 |
+
size 19592
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/public_gate/public_gate_report.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b79ab92f54ef5b314717b7374a9cda8d74cce8a43ed3a393dd006286bec88825
|
| 3 |
+
size 936
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/public_gate/staged_input_manifest.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:617d3c9ba182740afb4d1a8723deea5141ca60ca726e00e7364c186fd7224c9f
|
| 3 |
+
size 20343
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/runtime_result.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0362ad6233db8f70e74ab485257a973edba1e795739221eb8d63b28409d3eb62
|
| 3 |
+
size 437
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/public/staged_features.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5a1cb02abaf420d49bbf426e8d98820cac1ee0712808f84e1add5f989702bfb5
|
| 3 |
+
size 4350
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/public/test.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3321107cd4eb2ecfc26606c36779c9c019cd8819078c2c782db9638870417ffb
|
| 3 |
+
size 1383062
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/public/val.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f244b4756876af1cb6945def77c203f9ed6623a2356b198441f6acc066f3ab5d
|
| 3 |
+
size 1384259
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/tvae/adapter_report.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e5e81e1c4ce0156b58fee0301a62450f4d5a982cf9dc4ecbce0dc3fec4887d0b
|
| 3 |
+
size 307
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/staged/tvae/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/m2/tvae/tvae-m2-20260321_062136/staged/tvae/model_input_manifest.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:52c6ef50e88281ad2efa94879d9bc602eef7959730fcba451c83b52f4ae1412e
|
| 3 |
+
size 20526
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/tvae-m2-1000-20260321_065656.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ea0230b012f818fb149ee813b47e2d232366b0d38d2a298706643a49b66d96c
|
| 3 |
+
size 270252
|
syntheticSuccess/m2/tvae/tvae-m2-20260321_062136/tvae_metadata.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:629aabf4a5f3b26401fd0d908d4f1fb6e53dc9c4bb5d7871041135bef1c4bf05
|
| 3 |
+
size 3184
|