Resume SynthData0523 main/c19 batch 1
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +45 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/_arf_generate.py +93 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/_arf_train.py +37 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/arf-c19-32759-20260424_052254.csv +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/arf_model.pkl +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/gen_20260424_052254.log +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/input_snapshot.json +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/public_gate/normalized_schema_snapshot.json +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/public_gate/public_gate_report.json +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/public_gate/staged_input_manifest.json +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/runtime_result.json +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/arf/adapter_report.json +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/arf/adapter_transforms_applied.json +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/arf/model_input_manifest.json +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/public/staged_features.json +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/public/test.csv +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/public/train.csv +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/public/val.csv +3 -0
- SynthData0523/main/c19/arf/arf-c19-20260424_051258/train_20260424_051302.log +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/_bayesnet_generate.py +105 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/_bayesnet_train.py +133 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet-c19-32759-20260422_192846.csv +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_coltypes.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_model.pkl +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/const_cols.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/gen_20260422_192846.log +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/input_snapshot.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/normalized_schema_snapshot.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/public_gate_report.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/staged_input_manifest.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/runtime_result.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/adapter_report.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/adapter_transforms_applied.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/model_input_manifest.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/staged_features.json +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/test.csv +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/train.csv +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/val.csv +3 -0
- SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/train_20260422_192819.log +3 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/_ctgan_generate.py +18 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/ctgan-c19-32759-20260422_120804.csv +3 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/ctgan_metadata.json +3 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/gen_20260422_120804.log +3 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/input_snapshot.json +3 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/models_300epochs/ctgan_300epochs.pt +3 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/models_300epochs/train_20260422_031311.log +3 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/public_gate/normalized_schema_snapshot.json +3 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/public_gate/public_gate_report.json +3 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/public_gate/staged_input_manifest.json +3 -0
- SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/runtime_result.json +3 -0
.gitattributes
CHANGED
|
@@ -2647,3 +2647,48 @@ SynthData0523/main/c18/tvae/tvae-c18-20260511_061930/staged/tvae/adapter_transfo
|
|
| 2647 |
SynthData0523/main/c18/tvae/tvae-c18-20260511_061930/staged/tvae/model_input_manifest.json filter=lfs diff=lfs merge=lfs -text
|
| 2648 |
SynthData0523/main/c18/tvae/tvae-c18-20260511_061930/tvae-c18-103976-20260511_174828.csv filter=lfs diff=lfs merge=lfs -text
|
| 2649 |
SynthData0523/main/c18/tvae/tvae-c18-20260511_061930/tvae_metadata.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2647 |
SynthData0523/main/c18/tvae/tvae-c18-20260511_061930/staged/tvae/model_input_manifest.json filter=lfs diff=lfs merge=lfs -text
|
| 2648 |
SynthData0523/main/c18/tvae/tvae-c18-20260511_061930/tvae-c18-103976-20260511_174828.csv filter=lfs diff=lfs merge=lfs -text
|
| 2649 |
SynthData0523/main/c18/tvae/tvae-c18-20260511_061930/tvae_metadata.json filter=lfs diff=lfs merge=lfs -text
|
| 2650 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/arf-c19-32759-20260424_052254.csv filter=lfs diff=lfs merge=lfs -text
|
| 2651 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/arf_model.pkl filter=lfs diff=lfs merge=lfs -text
|
| 2652 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/gen_20260424_052254.log filter=lfs diff=lfs merge=lfs -text
|
| 2653 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/input_snapshot.json filter=lfs diff=lfs merge=lfs -text
|
| 2654 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/public_gate/normalized_schema_snapshot.json filter=lfs diff=lfs merge=lfs -text
|
| 2655 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/public_gate/public_gate_report.json filter=lfs diff=lfs merge=lfs -text
|
| 2656 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/public_gate/staged_input_manifest.json filter=lfs diff=lfs merge=lfs -text
|
| 2657 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/runtime_result.json filter=lfs diff=lfs merge=lfs -text
|
| 2658 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/arf/adapter_report.json filter=lfs diff=lfs merge=lfs -text
|
| 2659 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/arf/adapter_transforms_applied.json filter=lfs diff=lfs merge=lfs -text
|
| 2660 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/arf/model_input_manifest.json filter=lfs diff=lfs merge=lfs -text
|
| 2661 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/public/staged_features.json filter=lfs diff=lfs merge=lfs -text
|
| 2662 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/public/test.csv filter=lfs diff=lfs merge=lfs -text
|
| 2663 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/public/train.csv filter=lfs diff=lfs merge=lfs -text
|
| 2664 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/staged/public/val.csv filter=lfs diff=lfs merge=lfs -text
|
| 2665 |
+
SynthData0523/main/c19/arf/arf-c19-20260424_051258/train_20260424_051302.log filter=lfs diff=lfs merge=lfs -text
|
| 2666 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet-c19-32759-20260422_192846.csv filter=lfs diff=lfs merge=lfs -text
|
| 2667 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_coltypes.json filter=lfs diff=lfs merge=lfs -text
|
| 2668 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/bayesnet_model.pkl filter=lfs diff=lfs merge=lfs -text
|
| 2669 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/const_cols.json filter=lfs diff=lfs merge=lfs -text
|
| 2670 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/gen_20260422_192846.log filter=lfs diff=lfs merge=lfs -text
|
| 2671 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/input_snapshot.json filter=lfs diff=lfs merge=lfs -text
|
| 2672 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/normalized_schema_snapshot.json filter=lfs diff=lfs merge=lfs -text
|
| 2673 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/public_gate_report.json filter=lfs diff=lfs merge=lfs -text
|
| 2674 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/public_gate/staged_input_manifest.json filter=lfs diff=lfs merge=lfs -text
|
| 2675 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/runtime_result.json filter=lfs diff=lfs merge=lfs -text
|
| 2676 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/adapter_report.json filter=lfs diff=lfs merge=lfs -text
|
| 2677 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/adapter_transforms_applied.json filter=lfs diff=lfs merge=lfs -text
|
| 2678 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/bayesnet/model_input_manifest.json filter=lfs diff=lfs merge=lfs -text
|
| 2679 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/staged_features.json filter=lfs diff=lfs merge=lfs -text
|
| 2680 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/test.csv filter=lfs diff=lfs merge=lfs -text
|
| 2681 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/train.csv filter=lfs diff=lfs merge=lfs -text
|
| 2682 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/staged/public/val.csv filter=lfs diff=lfs merge=lfs -text
|
| 2683 |
+
SynthData0523/main/c19/bayesnet/bayesnet-c19-20260422_192809/train_20260422_192819.log filter=lfs diff=lfs merge=lfs -text
|
| 2684 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/ctgan-c19-32759-20260422_120804.csv filter=lfs diff=lfs merge=lfs -text
|
| 2685 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/ctgan_metadata.json filter=lfs diff=lfs merge=lfs -text
|
| 2686 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/gen_20260422_120804.log filter=lfs diff=lfs merge=lfs -text
|
| 2687 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/input_snapshot.json filter=lfs diff=lfs merge=lfs -text
|
| 2688 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/models_300epochs/ctgan_300epochs.pt filter=lfs diff=lfs merge=lfs -text
|
| 2689 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/models_300epochs/train_20260422_031311.log filter=lfs diff=lfs merge=lfs -text
|
| 2690 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/public_gate/normalized_schema_snapshot.json filter=lfs diff=lfs merge=lfs -text
|
| 2691 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/public_gate/public_gate_report.json filter=lfs diff=lfs merge=lfs -text
|
| 2692 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/public_gate/staged_input_manifest.json filter=lfs diff=lfs merge=lfs -text
|
| 2693 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/runtime_result.json filter=lfs diff=lfs merge=lfs -text
|
| 2694 |
+
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/staged/ctgan/adapter_report.json filter=lfs diff=lfs merge=lfs -text
|
SynthData0523/main/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")
|
SynthData0523/main/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")
|
SynthData0523/main/c19/arf/arf-c19-20260424_051258/arf-c19-32759-20260424_052254.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4c42bfc76d10db5400b66c91a099098e561162ca8cf6ffbf8b1b8a4ba8d9f86d
|
| 3 |
+
size 51466383
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/c19/arf/arf-c19-20260424_051258/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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")
|
SynthData0523/main/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")
|
SynthData0523/main/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:0bf1d0a877ba735c5fad36e25343883d54170ac0f24b87dcfd22e0df97bc3fe8
|
| 3 |
+
size 12002424
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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
|
SynthData0523/main/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")
|
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/ctgan-c19-32759-20260422_120804.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:42968504093193c724698f10a378f450f2a7395fcc498ba794a8455f136aac96
|
| 3 |
+
size 47984045
|
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/ctgan_metadata.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:761007e5936a02e408256fa21d2e8db8b85fc746a47d8b03a9e4bc007150ec0e
|
| 3 |
+
size 1137
|
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/gen_20260422_120804.log
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cf76534d353e6ba75c7db393080d194422e95a9bb9a25eff779f994e0c3d2f67
|
| 3 |
+
size 297
|
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/input_snapshot.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:05e336c5e655f0aaa032f285dac0f738602f58dc9ddacc55f901bd8b63103520
|
| 3 |
+
size 1363
|
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/models_300epochs/ctgan_300epochs.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d212eecbb082d7ea153cde5bac2a5d595e367f28062c913b8ccc2a1eec6f9199
|
| 3 |
+
size 6525627939
|
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/models_300epochs/train_20260422_031311.log
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8432f4f19dfc3e85d71558d61a647d69f6bfa67f01288feec6335229f0388475
|
| 3 |
+
size 2922
|
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/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
|
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/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
|
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/public_gate/staged_input_manifest.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d8135490dd7ee751cce5e8b97b46674b2467e8c2f81c42d736218591c3df87d
|
| 3 |
+
size 16661
|
SynthData0523/main/c19/ctgan/ctgan-c19-20260422_031259/runtime_result.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f982e86c34d3cb7856f74e9dbe669bd85c52de918a84f5ae5c6751d17f1c8fa2
|
| 3 |
+
size 609
|