Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87c64278ba |
@@ -489,7 +489,9 @@ def build_parser() -> argparse.ArgumentParser:
|
|||||||
_add_model_args(p_build, required=True)
|
_add_model_args(p_build, required=True)
|
||||||
p_build.add_argument("--n-classes", type=int, default=11)
|
p_build.add_argument("--n-classes", type=int, default=11)
|
||||||
p_build.add_argument("--seed", type=int, default=0)
|
p_build.add_argument("--seed", type=int, default=0)
|
||||||
p_build.add_argument("--out", default=None, help="Write the JSON payload to PATH instead of stdout")
|
p_build.add_argument(
|
||||||
|
"--out", default=None, help="Write the JSON payload to PATH instead of stdout"
|
||||||
|
)
|
||||||
p_build.set_defaults(func=_cmd_build)
|
p_build.set_defaults(func=_cmd_build)
|
||||||
|
|
||||||
p_store = sub.add_parser("store", help="build a signal store (pod5+labels or synthetic)")
|
p_store = sub.add_parser("store", help="build a signal store (pod5+labels or synthetic)")
|
||||||
|
|||||||
+11
-10
@@ -56,6 +56,7 @@ PER_GENUS_NAME = "per_genus.parquet"
|
|||||||
CONFUSION_NAME = "confusion.npz"
|
CONFUSION_NAME = "confusion.npz"
|
||||||
OPEN_SET_NAME = "open_set.json"
|
OPEN_SET_NAME = "open_set.json"
|
||||||
ERRORS_NAME = "errors.parquet"
|
ERRORS_NAME = "errors.parquet"
|
||||||
|
TEST_SPLIT_NAME = "test_split.parquet"
|
||||||
TRAP_REPORT_NAME = "trap_report.json"
|
TRAP_REPORT_NAME = "trap_report.json"
|
||||||
GATE_NAME = "gate_verdict.json"
|
GATE_NAME = "gate_verdict.json"
|
||||||
|
|
||||||
@@ -281,9 +282,7 @@ def evaluate_val(
|
|||||||
_, val_loader, _ = make_loaders(store, splits, cfg.train)
|
_, val_loader, _ = make_loaders(store, splits, cfg.train)
|
||||||
val_logits, val_y = predict(probe, val_loader, device, amp)
|
val_logits, val_y = predict(probe, val_loader, device, amp)
|
||||||
val_pred = val_logits.argmax(axis=1)
|
val_pred = val_logits.argmax(axis=1)
|
||||||
report = closed_set_report(
|
report = closed_set_report(val_y, val_pred, splits.genera, n_boot=n_boot, seed=cfg.data.seed)
|
||||||
val_y, val_pred, splits.genera, n_boot=n_boot, seed=cfg.data.seed
|
|
||||||
)
|
|
||||||
payload = {
|
payload = {
|
||||||
"run_id": cfg.run_id,
|
"run_id": cfg.run_id,
|
||||||
"split": "val",
|
"split": "val",
|
||||||
@@ -307,7 +306,9 @@ def evaluate_test(
|
|||||||
Predicts val (for tau calibration) and test; writes
|
Predicts val (for tau calibration) and test; writes
|
||||||
``per_genus.parquet``, ``confusion.npz`` (matrix / genera / y_true /
|
``per_genus.parquet``, ``confusion.npz`` (matrix / genera / y_true /
|
||||||
y_pred / msp), ``errors.parquet`` (per-error rows), ``open_set.json``,
|
y_pred / msp), ``errors.parquet`` (per-error rows), ``open_set.json``,
|
||||||
``report.json`` and — when a trap store is given —
|
``test_split.parquet`` (per-read test-split membership, so external
|
||||||
|
baselines can be evaluated on the identical test read set) and
|
||||||
|
``report.json`` — and, when a trap store is given,
|
||||||
``trap_report.json`` (TP2: false-accept rates at tau, family-collapsed
|
``trap_report.json`` (TP2: false-accept rates at tau, family-collapsed
|
||||||
rates, MSP/margin histograms, top-3 retrieval, centroids).
|
rates, MSP/margin histograms, top-3 retrieval, centroids).
|
||||||
|
|
||||||
@@ -338,12 +339,14 @@ def evaluate_test(
|
|||||||
val_logits, val_y = predict(probe, val_loader, device, amp)
|
val_logits, val_y = predict(probe, val_loader, device, amp)
|
||||||
test_logits, test_y = predict(probe, test_loader, device, amp)
|
test_logits, test_y = predict(probe, test_loader, device, amp)
|
||||||
test_pred = test_logits.argmax(axis=1)
|
test_pred = test_logits.argmax(axis=1)
|
||||||
report = closed_set_report(
|
report = closed_set_report(test_y, test_pred, splits.genera, n_boot=n_boot, seed=cfg.data.seed)
|
||||||
test_y, test_pred, splits.genera, n_boot=n_boot, seed=cfg.data.seed
|
|
||||||
)
|
|
||||||
open_set = open_set_probe_report(val_logits, val_y, test_logits, test_y)
|
open_set = open_set_probe_report(val_logits, val_y, test_logits, test_y)
|
||||||
test_msp = msp(test_logits)
|
test_msp = msp(test_logits)
|
||||||
run_dir.mkdir(parents=True, exist_ok=True)
|
run_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
test_rows = manifest.filter(pl.col("window_id").is_in(splits.test.tolist()))
|
||||||
|
test_rows.select("window_id", "read_id", "genus", "source_run").sort("window_id").write_parquet(
|
||||||
|
run_dir / TEST_SPLIT_NAME
|
||||||
|
)
|
||||||
report.per_genus.write_parquet(run_dir / PER_GENUS_NAME)
|
report.per_genus.write_parquet(run_dir / PER_GENUS_NAME)
|
||||||
np.savez_compressed(
|
np.savez_compressed(
|
||||||
run_dir / CONFUSION_NAME,
|
run_dir / CONFUSION_NAME,
|
||||||
@@ -481,9 +484,7 @@ def _read_run_summary(run_dir: Path) -> dict[str, Any]:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def evaluate_gate(
|
def evaluate_gate(runs: Sequence[Path], control: Path, chance_tol: float = 1.5) -> GateVerdict:
|
||||||
runs: Sequence[Path], control: Path, chance_tol: float = 1.5
|
|
||||||
) -> GateVerdict:
|
|
||||||
"""Decide the E1-v2 gate over run directories and write the verdict.
|
"""Decide the E1-v2 gate over run directories and write the verdict.
|
||||||
|
|
||||||
Logic (v2 §6, chance = 1/n_classes from the control run's config):
|
Logic (v2 §6, chance = 1/n_classes from the control run's config):
|
||||||
|
|||||||
Reference in New Issue
Block a user