TabQueryBench commited on
Commit
bbf8374
·
verified ·
1 Parent(s): 4425e1b

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/_bayesnet_generate.py +105 -0
  2. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/_bayesnet_train.py +133 -0
  3. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/bayesnet-c7-10368-20260429_031053.csv +3 -0
  4. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/bayesnet_coltypes.json +3 -0
  5. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/bayesnet_model.pkl +3 -0
  6. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/const_cols.json +3 -0
  7. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/gen_20260429_031053.log +3 -0
  8. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/input_snapshot.json +3 -0
  9. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/public_gate/normalized_schema_snapshot.json +3 -0
  10. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/public_gate/public_gate_report.json +3 -0
  11. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/public_gate/staged_input_manifest.json +3 -0
  12. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/runtime_result.json +3 -0
  13. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/bayesnet/adapter_report.json +3 -0
  14. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/bayesnet/adapter_transforms_applied.json +3 -0
  15. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/bayesnet/model_input_manifest.json +3 -0
  16. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/public/staged_features.json +3 -0
  17. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/public/test.csv +3 -0
  18. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/public/train.csv +3 -0
  19. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/public/val.csv +3 -0
  20. syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/train_20260429_031038.log +3 -0
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/_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-Benchmark-trainonly-v1/c7/bayesnet/bayesnet-c7-20260429_031038/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(10368)
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-Benchmark-trainonly-v1/c7/bayesnet/bayesnet-c7-20260429_031038/bayesnet-c7-10368-20260429_031053.csv", index=False)
105
+ print(f"[BayesNet] Generated {len(final)} rows (requested {num_rows}) -> /work/output-Benchmark-trainonly-v1/c7/bayesnet/bayesnet-c7-20260429_031038/bayesnet-c7-10368-20260429_031053.csv")
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/_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-Benchmark-trainonly-v1/c7/bayesnet/bayesnet-c7-20260429_031038/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-Benchmark-trainonly-v1/c7/bayesnet/bayesnet-c7-20260429_031038/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-Benchmark-trainonly-v1/c7/bayesnet/bayesnet-c7-20260429_031038/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-Benchmark-trainonly-v1/c7/bayesnet/bayesnet-c7-20260429_031038/bayesnet_model.pkl", "wb") as _f:
132
+ pickle.dump(bundle, _f)
133
+ print(f"[BayesNet] Model saved -> /work/output-Benchmark-trainonly-v1/c7/bayesnet/bayesnet-c7-20260429_031038/bayesnet_model.pkl")
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/bayesnet-c7-10368-20260429_031053.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ec483f732565f4c875574544cd638c236741ab73b64670c524b307e81d3762a
3
+ size 847720
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/bayesnet_coltypes.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1cde99b1974184c5df0d3fccfade8f11ca79c02b92a5c659dc5ba44c4aefe1ab
3
+ size 635
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/bayesnet_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:342563385d822291efea03ef34858a3fa7a9c37695d1d9aa761ad616bb14bd4f
3
+ size 5680
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/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/c7/bayesnet/bayesnet-c7-20260429_031038/gen_20260429_031053.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e814c1f07c97634a205072c6af264b79105ca899b88cdfec9e2a14198170e22e
3
+ size 3664
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/input_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f14cece186149619179cfb8958e71a76b2fbcabb5fa6692b86991573a8d3b9d4
3
+ size 1349
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/public_gate/normalized_schema_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5dd68094a5d8fc40d291695c5aa12bc01cfe8d3a62848b4bcfd82c2e88ed19c9
3
+ size 4177
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/public_gate/public_gate_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f08566bcd78a9005059bf27f5f9ecf74954e2be289410d19100e900577f651ea
3
+ size 912
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/public_gate/staged_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10fcaae37cee3c1cecb035645a99b986db3843874586926587633a65d1d6d835
3
+ size 4993
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/runtime_result.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a94883ffb73e985e889ae5e8791d48ba9a58afdf509bbb913053485e0feb65f2
3
+ size 616
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/bayesnet/adapter_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:906add5afc393cc78cc1424a22b842aec8297d88dc80cb495fe3c24ed7249e55
3
+ size 324
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/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/c7/bayesnet/bayesnet-c7-20260429_031038/staged/bayesnet/model_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b718a92aed504ba5d07eb0fb848edd8d33a916bc26a39393436602dc0e3f5f7
3
+ size 5193
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/public/staged_features.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07596ae0689482090a05749dba332eca061d863cde5d8bf7a83e8c2c92abb330
3
+ size 851
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/public/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2042076337d5c37c6476e6bca2bd33cb5a171450c27894534ef50ac223256058
3
+ size 106030
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/public/train.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b37f6b2ef5257f40bd826ac956749881f0f474362bdb56e8c5728ad629242e3a
3
+ size 847349
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/staged/public/val.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eff6dec27c3740661a1ae84dea391d690dfb60342bfd5d7527b903fdd6009780
3
+ size 106192
syntheticSuccess/c7/bayesnet/bayesnet-c7-20260429_031038/train_20260429_031038.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4111c669d5532e874b7f7b68b102dfe387746d6756cffa5d3ad8d7cb0ea7f147
3
+ size 3741