TabQueryBench commited on
Commit
57e24c7
·
verified ·
1 Parent(s): f810f8b

Add files using upload-large-folder tool

Browse files
syntheticSuccess/m8/arf/arf-m8-20260502_160718/_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(36168)
49
+ c_csv = "/work/output-Benchmark-trainonly-v1/m8/arf/arf-m8-20260502_160718/staged/public/train.csv"
50
+ with open("/work/output-Benchmark-trainonly-v1/m8/arf/arf-m8-20260502_160718/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 = 'm8'
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/m8/arf/arf-m8-20260502_160718/arf-m8-36168-20260502_160912.csv", index=False)
93
+ print(f"[ARF] Generated {len(syn)} rows (requested {n_target}) -> /work/output-Benchmark-trainonly-v1/m8/arf/arf-m8-20260502_160718/arf-m8-36168-20260502_160912.csv")
syntheticSuccess/m8/arf/arf-m8-20260502_160718/_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/m8/arf/arf-m8-20260502_160718/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/m8/arf/arf-m8-20260502_160718/arf_model.pkl", "wb") as f:
36
+ pickle.dump(model, f)
37
+ print(f"[ARF] Model saved -> /work/output-Benchmark-trainonly-v1/m8/arf/arf-m8-20260502_160718/arf_model.pkl")
syntheticSuccess/m8/arf/arf-m8-20260502_160718/arf-m8-36168-20260502_160912.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba443b107a71b5faa2d7231d61078f719b9b9d1a399531e7f7c648d886139ff1
3
+ size 6040860
syntheticSuccess/m8/arf/arf-m8-20260502_160718/arf_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8242a5bf5f6e3d6ebaa2cd60d719b19cb7c480da867300fb8a50f13018a0ef7a
3
+ size 170779501
syntheticSuccess/m8/arf/arf-m8-20260502_160718/gen_20260502_160912.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d09af1cac5fbd3b9e677fa7fd88f0c0da7f9daa4d65001f9d074137d60ccb56e
3
+ size 3567
syntheticSuccess/m8/arf/arf-m8-20260502_160718/input_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83ba036d2925404b48cb1755d4351c1fa710bd06430ca3cf5a146ac618f74c0d
3
+ size 1345
syntheticSuccess/m8/arf/arf-m8-20260502_160718/public_gate/normalized_schema_snapshot.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d733310afeedb79582ccecc72b050f6a9a712817177584d3824924c50e502e38
3
+ size 7627
syntheticSuccess/m8/arf/arf-m8-20260502_160718/public_gate/public_gate_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d069ba59e0bad764d31cf1059ffe64fcc37d324eba6441fdff3756c384a2efd7
3
+ size 908
syntheticSuccess/m8/arf/arf-m8-20260502_160718/public_gate/staged_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc1288bb580b5ff15549114a8afd2f97b3618a266011114b57e2c55332c0c10c
3
+ size 8393
syntheticSuccess/m8/arf/arf-m8-20260502_160718/runtime_result.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4b4149322a0ec2937163889dacd3cb16d1685d81bab831c83e3b2d21f5cc6b1
3
+ size 869
syntheticSuccess/m8/arf/arf-m8-20260502_160718/staged/arf/adapter_report.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec88a9bcb3af2273f887a211a06fa6a23d623b8aca1d5f0f3a30384fbc9f6375
3
+ size 309
syntheticSuccess/m8/arf/arf-m8-20260502_160718/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/m8/arf/arf-m8-20260502_160718/staged/arf/model_input_manifest.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7bff3a3c10a27a267c59f4fe91d0f8a0c832a5973b1415902519f8d0843ce954
3
+ size 8578
syntheticSuccess/m8/arf/arf-m8-20260502_160718/staged/public/staged_features.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0cf7f5cbab67fd23b227d3d6dd45fee61797fb10d962495c5e6e65ae5dbcb5f0
3
+ size 1570
syntheticSuccess/m8/arf/arf-m8-20260502_160718/staged/public/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6221943e422e75c8317b79b7ef93e9cd01f61fdd8de6ce42909a8e4610966310
3
+ size 370991
syntheticSuccess/m8/arf/arf-m8-20260502_160718/staged/public/train.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f9cbb71aa793de19869a138d41aea5808f772b31082741b185ffb8ca7b821833
3
+ size 2964802
syntheticSuccess/m8/arf/arf-m8-20260502_160718/staged/public/val.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ee8612128aae92155906abc0fdc752ac24fd04d63c78c080c89e3900efe6525
3
+ size 370535
syntheticSuccess/m8/arf/arf-m8-20260502_160718/train_20260502_160718.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0ef062957d75d8a0ed6fa7ada811780c5a2d77ef3d7a6e054db4341c85e241f
3
+ size 498