Add files using upload-large-folder tool
Browse filesFiles changed (18)
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/_arf_generate.pyAdded+93
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/_arf_train.pyAdded+37
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/arf-m6-9864-20260429_032614.csvAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/arf_model.pklAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/gen_20260429_032614.logAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/input_snapshot.jsonAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/public_gate/normalized_schema_snapshot.jsonAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/public_gate/public_gate_report.jsonAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/public_gate/staged_input_manifest.jsonAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/runtime_result.jsonAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/arf/adapter_report.jsonAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/arf/adapter_transforms_applied.jsonAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/arf/model_input_manifest.jsonAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/public/staged_features.jsonAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/public/test.csvAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/public/train.csvAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/public/val.csvAdded+3
- syntheticSuccess/m6/arf/arf-m6-20260429_032047/train_20260429_032047.logAdded+3
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293import pickleimport numpy as npimport pandas as pd
def _bootstrap_from_train(c_csv: str, n_target: int, seed: int = 42) -> pd.DataFrame: """当 arfpy.forge 完全不可用时,从训练 CSV 有放回抽样,保证行数与列对齐。""" src = pd.read_csv(c_csv, encoding="utf-8-sig", low_memory=False) src = src.replace([np.inf, -np.inf], np.nan).dropna(axis=1, how="all") src = src.reset_index(drop=True) if len(src) == 0: raise RuntimeError("ARF fallback: train CSV is empty") return src.sample(n=n_target, replace=True, random_state=seed).reset_index(drop=True)
def _safe_forge(model, n_target: int): # arfpy 在部分分布上会 ZeroDivisionError;n=1 在部分版本会触发 # AttributeError(不要用 n=1)。失败返回 None,由外层走 bootstrap。 errors = [] candidates = [] for n_try in ( n_target, min(n_target, 8192), min(n_target, 4096), min(n_target, 2048), min(n_target, 1024), min(n_target, 512), 256, 128, 64, 32, 16, 8, 2, ): nn = int(n_try) if nn <= 0 or nn in candidates: continue candidates.append(nn) for n_try in candidates: try: out = model.forge(n=n_try).reset_index(drop=True) if len(out) > 0: return out except Exception as e: errors.append(f"n={n_try}: {type(e).__name__}: {e}") print("[ARF] forge failed after retries; last errors:", " | ".join(errors[-4:])) return None
n_target = int(9864)c_csv = "/work/output-Benchmark-trainonly-v1/m6/arf/arf-m6-20260429_032047/staged/public/train.csv"with open("/work/output-Benchmark-trainonly-v1/m6/arf/arf-m6-20260429_032047/arf_model.pkl", "rb") as f: model = pickle.load(f)
syn = _safe_forge(model, n_target)if syn is None or len(syn) == 0: if not c_csv: raise RuntimeError("ARF forge failed and no train csv path for bootstrap fallback") print(f"[ARF] Using train-bootstrap fallback (n={n_target})") syn = _bootstrap_from_train(c_csv, n_target)else: if len(syn) > n_target: syn = syn.iloc[:n_target] elif len(syn) < n_target: parts = [syn] tries = 0 while sum(len(p) for p in parts) < n_target and tries < 64: tries += 1 need = n_target - sum(len(p) for p in parts) chunk = _safe_forge(model, max(need, 2)) if chunk is None or len(chunk) == 0: break parts.append(chunk) syn = pd.concat(parts, ignore_index=True).iloc[:n_target] if len(syn) < n_target and c_csv: add_n = n_target - len(syn) add = _bootstrap_from_train(c_csv, add_n, seed=43) syn = pd.concat([syn, add], ignore_index=True).iloc[:n_target]
_ds_id = 'm6'if _ds_id == "c19": # 仅 c19:object 列内裸换行会使 pivot 用 csv.reader 统计到的「记录数」大于 DataFrame 行数 → Sw。 for _col in syn.columns: if syn[_col].dtype == object: syn[_col] = ( syn[_col] .astype(str) .str.replace("\r\n", " ", regex=False) .str.replace("\n", " ", regex=False) .str.replace("\r", " ", regex=False) ) syn = syn.iloc[:n_target].reset_index(drop=True)
syn.to_csv("/work/output-Benchmark-trainonly-v1/m6/arf/arf-m6-20260429_032047/arf-m6-9864-20260429_032614.csv", index=False)print(f"[ARF] Generated {len(syn)} rows (requested {n_target}) -> /work/output-Benchmark-trainonly-v1/m6/arf/arf-m6-20260429_032047/arf-m6-9864-20260429_032614.csv")12345678910111213141516171819202122232425262728293031323334353637import pickleimport numpy as npimport pandas as pdfrom arfpy import arf
def _sanitize_for_arf(df: pd.DataFrame) -> pd.DataFrame: """缓解 forge 阶段 scipy.stats.truncnorm / 除零:处理 inf、NaN 与极端尾部。""" df = df.replace([np.inf, -np.inf], np.nan) df = df.dropna(axis=1, how="all") for col in df.select_dtypes(include=[np.number]).columns: med = df[col].median() if pd.isna(med): med = 0.0 df[col] = df[col].fillna(med) nu = int(df[col].nunique(dropna=True)) if nu <= 1: continue lo, hi = df[col].quantile(0.001), df[col].quantile(0.999) if pd.notna(lo) and pd.notna(hi) and lo < hi: df[col] = df[col].clip(lo, hi) return df
df = pd.read_csv("/work/output-Benchmark-trainonly-v1/m6/arf/arf-m6-20260429_032047/staged/public/train.csv")df = _sanitize_for_arf(df)print(f"[ARF] Training on {len(df)} rows, {len(df.columns)} cols")
model = arf.arf(x=df)if hasattr(model, "fit"): model.fit()elif hasattr(model, "forde"): model.forde()else: raise RuntimeError("arfpy API: no fit() / forde()")
with open("/work/output-Benchmark-trainonly-v1/m6/arf/arf-m6-20260429_032047/arf_model.pkl", "wb") as f: pickle.dump(model, f)print(f"[ARF] Model saved -> /work/output-Benchmark-trainonly-v1/m6/arf/arf-m6-20260429_032047/arf_model.pkl")123version https://git-lfs.github.com/spec/v1oid sha256:e131b12db9695b205eb97e35ed4baf665c6de67084e3117089dd0d357fa53710size 922076123version https://git-lfs.github.com/spec/v1oid sha256:c474e1d8dfe780936bff412e0b2b9015b6c85e4be93f788f3af9f32ccf6c8371size 75686526123version https://git-lfs.github.com/spec/v1oid sha256:3cc077131c12d5f2032fb426a39afb72ffb81224d2039b7888771220218b0d60size 4926123version https://git-lfs.github.com/spec/v1oid sha256:5734411134317ebe8a0239052e1d48298b4657ceacc9914c694e62b83805b0a3size 1344123version https://git-lfs.github.com/spec/v1oid sha256:9a347e1961ed33117b9d30b34fc15249721c7bd0b25fb31ac7f974d158104bddsize 8408123version https://git-lfs.github.com/spec/v1oid sha256:eab3321ed4d9b51e430632d2aedeca5d0260df7acff58b7d732c556dd377db9dsize 918123version https://git-lfs.github.com/spec/v1oid sha256:31ff90fdeee68fb82291c8e7721fa4b8ccb0ce7f0fa6d1e8c6b3e379baa611d0size 9174123version https://git-lfs.github.com/spec/v1oid sha256:c4764882ef9fb9949e3edce539e82219afe1961c2d0597c7a4b9810ce1d5d1fesize 575123version https://git-lfs.github.com/spec/v1oid sha256:cf7111e4fce96fca3bd546db16fb2be8a43e65b9e847b8b0c6ffe91a06735e5esize 309123version https://git-lfs.github.com/spec/v1oid sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945size 2123version https://git-lfs.github.com/spec/v1oid sha256:6ec1aab1f190a265e4a2f97cea80a76a231ecb85191714faed7dcabcc40de9b1size 9359123version https://git-lfs.github.com/spec/v1oid sha256:23eac1d28d264cb53a977ae6229286741b38cdeec8b02eb2ee5f9a2949661e29size 1780123version https://git-lfs.github.com/spec/v1oid sha256:d16d0389cb0fe4b23bab344dc10070de6678357a9452f9f620d0eeba66a6b12dsize 116376123version https://git-lfs.github.com/spec/v1oid sha256:e1f0338c367408dc21d5a4ec9cdc5d3fe8188916db6085f3fd326304a55551e1size 924849123version https://git-lfs.github.com/spec/v1oid sha256:cb9169f3c7213420491d9b709ee1cc650aeaed732fa77dcbd6ffe3583366b2d4size 116198123version https://git-lfs.github.com/spec/v1oid sha256:298d13ce543b6bb0c550ea0a1193e8cc1a62b93915e781e52ee34396c14bc66asize 733syntheticSuccess/m6/arf/arf-m6-20260429_032047/_arf_generate.pyAdded+93
syntheticSuccess/m6/arf/arf-m6-20260429_032047/_arf_train.pyAdded+37
syntheticSuccess/m6/arf/arf-m6-20260429_032047/arf-m6-9864-20260429_032614.csvAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/arf_model.pklAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/gen_20260429_032614.logAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/input_snapshot.jsonAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/public_gate/normalized_schema_snapshot.jsonAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/public_gate/public_gate_report.jsonAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/public_gate/staged_input_manifest.jsonAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/runtime_result.jsonAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/arf/adapter_report.jsonAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/arf/adapter_transforms_applied.jsonAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/arf/model_input_manifest.jsonAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/public/staged_features.jsonAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/public/test.csvAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/public/train.csvAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/staged/public/val.csvAdded+3
syntheticSuccess/m6/arf/arf-m6-20260429_032047/train_20260429_032047.logAdded+3