P4 (Volve field case). Add the deviated-well and Volve well builders (ml_porosity/data/deviated.py, volve_wells.py), the ml_porosity/volve/ pipeline, scripts 23-25, the run_p4 drivers and tests. The protocol configs/protocol_volve.yaml was locked at 2026-10-29T01:17:42Z before the run (.sha256, .lock.json) and is committed here after the run. Gate G-D failed: M2-Sa beats the selected B3 at 2/6 wells (lowo) and 3/6 (slot), coverage90 is about 0.47, and no method has blind-well skill (R2 < 0). A post hoc constant at the training-well mean beats every network, so G-D had no power. The dropped P4x exploratory run is kept as a record only (exploratory/, docs/research/p4-exploratory.md). Applicability and Teapot Dome (exploratory, pre-declared). Scripts 26-29 and docs/research/applicability-*.md: F3 and Volve fail C1 and pass C2; T3 power needs 5-18 blind wells with an exact reference; Teapot T0 and pilot P-a failed, so Teapot is stopped. Raw Teapot data stay gitignored. Manuscript (Pivot 1, level A). Reframe paper/ as a theory and synthetic benchmark paper: Propositions 3-6, Corollaries 3-4, T4 coverage (script 30) and the post hoc H2b bound check (script 31), with F3/Volve moved to Appendix B. Correct two earlier claims: the Berkson and classical bounds differ by 1.5-4.6x at the f^4-weighted band, and the bank gain exceeds the registered classical bound (7/8 wide cells at N = 16) but only 3/8 under the post hoc Berkson bound. Docs. Sync plan, AGENTS.md, README, report.html, theory and technical overview. The length pass for the venue is dropped by the user (plan section 12 item 25); the length risk stays recorded as R9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
3.0 KiB
Python
63 lines
3.0 KiB
Python
"""P4 Volve post hoc description (not part of protocol_volve; computed after G-D, for scale only).
|
||
|
||
Reads the registered combined-ensemble predictions (outputs/p4/summary/predictions.npz) and the calibrated reference,
|
||
and writes outputs/p4/posthoc/:
|
||
wells.csv per scheme and outer well: label statistics, a constant prediction at the pooled label mean of the outer
|
||
training wells (no seismic), and, per method (σ_a = 7 ms), RMSE split into mean bias and the SD of the error.
|
||
macro.csv the same, unweighted mean over wells per scheme.
|
||
Nothing here chooses a method, budget or setting, and no G-D number is changed.
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import json
|
||
|
||
import numpy as np
|
||
import pandas as pd
|
||
|
||
from ml_porosity.paths import outputs_dir
|
||
from ml_porosity.volve.data import VolveData, load_arrays
|
||
from ml_porosity.volve.folds import outer_folds
|
||
from ml_porosity.volve.protocol import load_protocol, source_config
|
||
|
||
|
||
def main() -> None:
|
||
p = load_protocol()
|
||
ref, sa = p["data"]["primary_reference"], p["registration"]["sigma_a_ms"]
|
||
full = VolveData(p, arrays=load_arrays())
|
||
summary = outputs_dir() / "p4" / "summary"
|
||
index = json.loads((summary / "prediction_index.json").read_text(encoding="utf-8"))
|
||
with np.load(summary / "predictions.npz") as z:
|
||
mu = {i: 100 * z[f"{i}/mu"] for i, e in enumerate(index)
|
||
if str(e["seed"]) == "ensemble" and e["sigma_a_ms"] == sa}
|
||
rows = []
|
||
for scheme in p["split"]["schemes"]:
|
||
for test, train in outer_folds(p["data"]["wells"], scheme, source_config(p)["p4"]):
|
||
y = 100 * full.y(test, ref)
|
||
ok = np.isfinite(y)
|
||
pooled = np.concatenate([100 * full.y(w, ref) for w in train])
|
||
const = float(np.nanmean(pooled))
|
||
row = dict(scheme=scheme, well=test, n=int(ok.sum()), label_mean=float(y[ok].mean()),
|
||
label_sd=float(y[ok].std()), train_mean=const,
|
||
const_rmse=float(np.sqrt(np.mean((const - y[ok]) ** 2))), const_bias=const - float(y[ok].mean()))
|
||
for i, e in enumerate(index):
|
||
if i in mu and e["scheme"] == scheme and e["test_well"] == test:
|
||
err = mu[i][ok] - y[ok]
|
||
m = e["method"]
|
||
row |= {f"{m}/rmse": float(np.sqrt(np.mean(err ** 2))), f"{m}/bias": float(err.mean()),
|
||
f"{m}/err_sd": float(err.std()), f"{m}/pred_sd": float(mu[i][ok].std())}
|
||
rows.append(row)
|
||
wells = pd.DataFrame(rows)
|
||
out = outputs_dir() / "p4" / "posthoc"
|
||
out.mkdir(parents=True, exist_ok=True)
|
||
wells.to_csv(out / "wells.csv", index=False, float_format="%.4f")
|
||
numeric = wells.drop(columns=["well"])
|
||
macro = numeric.groupby("scheme").mean()
|
||
abs_bias = wells.filter(like="bias").abs().groupby(wells.scheme).mean().add_prefix("abs_")
|
||
macro.join(abs_bias).to_csv(out / "macro.csv", float_format="%.4f")
|
||
print(macro.join(abs_bias).T.to_string(float_format="%.3f"))
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|