TabQueryBench commited on
Commit
ada4516
·
verified ·
1 Parent(s): eb3d400

Add files using upload-large-folder tool

Browse files
syntheticSuccess/n6/arf/arf-n6-20260429_031623/_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(6400)
49
+ c_csv = "/work/output-Benchmark-trainonly-v1/n6/arf/arf-n6-20260429_031623/staged/public/train.csv"
50
+ with open("/work/output-Benchmark-trainonly-v1/n6/arf/arf-n6-20260429_031623/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 = 'n6'
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-Benchmark-trainonly-v1/n6/arf/arf-n6-20260429_031623/arf-n6-6400-20260429_032002.csv", index=False)
93
+ print(f"[ARF] Generated {len(syn)} rows (requested {n_target}) -> /work/output-Benchmark-trainonly-v1/n6/arf/arf-n6-20260429_031623/arf-n6-6400-20260429_032002.csv")
syntheticSuccess/n6/arf/arf-n6-20260429_031623/_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-Benchmark-trainonly-v1/n6/arf/arf-n6-20260429_031623/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-Benchmark-trainonly-v1/n6/arf/arf-n6-20260429_031623/arf_model.pkl", "wb") as f:
36
+ pickle.dump(model, f)
37
+ print(f"[ARF] Model saved -> /work/output-Benchmark-trainonly-v1/n6/arf/arf-n6-20260429_031623/arf_model.pkl")
syntheticSuccess/n6/arf/arf-n6-20260429_031623/arf-n6-6400-20260429_032002.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ae8ee5b84bb67e1265ade5b331c64864e14c6797e803082a475317806cd8009
3
+ size 2028017
syntheticSuccess/n6/arf/arf-n6-20260429_031623/arf_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:543ad3fe9ba90e9e706eb17541a6a2f053c993fd4d9191b2aadbc3f4ffe02315
3
+ size 43688366
syntheticSuccess/n6/arf/arf-n6-20260429_031623/gen_20260429_032002.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cb012c75ca4ed9a4a060e80e72256a563c8fe672017de96a2d649ccb3e57858
3
+ size 719
syntheticSuccess/n6/arf/arf-n6-20260429_031623/input_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3c53d9d4b9fca88d825f26a329037086c61ddfa16ac34e09613e456a3bc2794
3
+ size 1342
syntheticSuccess/n6/arf/arf-n6-20260429_031623/public_gate/normalized_schema_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b240ee2cf62a2868bf54e3b4393eadd3d7751825bf4bb34743e85547f7cbcd3
3
+ size 7725
syntheticSuccess/n6/arf/arf-n6-20260429_031623/public_gate/public_gate_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:225732b90f81f74a3430523830af44cf151a7f15f2571a57ad83c2d55f982195
3
+ size 908
syntheticSuccess/n6/arf/arf-n6-20260429_031623/public_gate/staged_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2e735bab87ef0eacb3de3757cf198543e2584e4435199b850e396d6ae2fecc9
3
+ size 8491
syntheticSuccess/n6/arf/arf-n6-20260429_031623/runtime_result.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3e983fca4a8ce59749326496036ee714753ec9838c054c0ec9f4cd84db46ca0
3
+ size 575
syntheticSuccess/n6/arf/arf-n6-20260429_031623/staged/arf/adapter_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d4452bfd1b74cc27fb339a0bd5c9efa9270e7612713692a61f7c06c6c27d579f
3
+ size 309
syntheticSuccess/n6/arf/arf-n6-20260429_031623/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/n6/arf/arf-n6-20260429_031623/staged/arf/model_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de248c41d95b16504142fc01f092cf6ff89db4107f1a4cc57bb91485564af79c
3
+ size 8676
syntheticSuccess/n6/arf/arf-n6-20260429_031623/staged/public/staged_features.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e2869694dd92d59628a62fdd1349d4dd69eb6608ed9b0fdeb4b0800b6334d81
3
+ size 1520
syntheticSuccess/n6/arf/arf-n6-20260429_031623/staged/public/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1922293e501d8f17f56a321a1305e44d20a6ad7ed67e97af754dea170989fc5
3
+ size 39918
syntheticSuccess/n6/arf/arf-n6-20260429_031623/staged/public/train.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8545a9761061bd99d67935948928e2840e6ae4b5c9760cad2de82198676db2b
3
+ size 316902
syntheticSuccess/n6/arf/arf-n6-20260429_031623/staged/public/val.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60a3dd7f655f8086e53402dcdcfa42297d586d8483f2afd6e1bbc6bd3521303f
3
+ size 39705
syntheticSuccess/n6/arf/arf-n6-20260429_031623/train_20260429_031623.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:88df5cd7df34aa12f7435d49946537a3792b88550158af905d44115fd0b43118
3
+ size 781