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

Add files using upload-large-folder tool

Browse files
syntheticSuccess/c7/arf/arf-c7-20260429_030948/_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(10368)
49
+ c_csv = "/work/output-Benchmark-trainonly-v1/c7/arf/arf-c7-20260429_030948/staged/public/train.csv"
50
+ with open("/work/output-Benchmark-trainonly-v1/c7/arf/arf-c7-20260429_030948/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 = 'c7'
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/c7/arf/arf-c7-20260429_030948/arf-c7-10368-20260429_031026.csv", index=False)
93
+ print(f"[ARF] Generated {len(syn)} rows (requested {n_target}) -> /work/output-Benchmark-trainonly-v1/c7/arf/arf-c7-20260429_030948/arf-c7-10368-20260429_031026.csv")
syntheticSuccess/c7/arf/arf-c7-20260429_030948/_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/c7/arf/arf-c7-20260429_030948/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/c7/arf/arf-c7-20260429_030948/arf_model.pkl", "wb") as f:
36
+ pickle.dump(model, f)
37
+ print(f"[ARF] Model saved -> /work/output-Benchmark-trainonly-v1/c7/arf/arf-c7-20260429_030948/arf_model.pkl")
syntheticSuccess/c7/arf/arf-c7-20260429_030948/arf-c7-10368-20260429_031026.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:66bc5cb299efafaea27685aa7dabdd62ede6e19adf9aae833cfe6c8c6aa6b81c
3
+ size 846612
syntheticSuccess/c7/arf/arf-c7-20260429_030948/arf_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d8786230db2bbc8dec7374177bbdc74810e36d36ad685dcdba983ed5e6e3f84c
3
+ size 44356271
syntheticSuccess/c7/arf/arf-c7-20260429_030948/gen_20260429_031026.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f94fa2b074d235488ffe68c5133b8e6c8361d97a22d7ac461165f2b363bbbaa1
3
+ size 3250
syntheticSuccess/c7/arf/arf-c7-20260429_030948/input_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9fa997cdad2bc623738861147a6af6758eadb4b745f3d13e434a27de38572b0b
3
+ size 1344
syntheticSuccess/c7/arf/arf-c7-20260429_030948/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/arf/arf-c7-20260429_030948/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/arf/arf-c7-20260429_030948/public_gate/staged_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:23dd606bde023620b34436e58fdef8d4c6fe20c8bd922adb655ebab9614122b7
3
+ size 4943
syntheticSuccess/c7/arf/arf-c7-20260429_030948/runtime_result.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:867f666b90ee2c04d23d27f7353e27bda5597a81c4ed706b1a3bc21f9a291387
3
+ size 576
syntheticSuccess/c7/arf/arf-c7-20260429_030948/staged/arf/adapter_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afd4342f12f2ae85f0422fdaf93c5c4d07f11d00cc11a257054ee442210e8b94
3
+ size 309
syntheticSuccess/c7/arf/arf-c7-20260429_030948/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/c7/arf/arf-c7-20260429_030948/staged/arf/model_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd356b1e3c6650404bac66959a42330cb773dceeb875c2cc4b27d0a4c2a4ffc9
3
+ size 5128
syntheticSuccess/c7/arf/arf-c7-20260429_030948/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/arf/arf-c7-20260429_030948/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/arf/arf-c7-20260429_030948/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/arf/arf-c7-20260429_030948/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/arf/arf-c7-20260429_030948/train_20260429_030948.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:872a5d80f7aabdecef7e9cb7ef3d751219c9b6a70b1427bda23e39a521d5012c
3
+ size 497