Datasets:
File size: 1,652 Bytes
d67b900 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #!/usr/bin/env python3
"""Load the dataset, check it, and look at what the agents actually see."""
from pathlib import Path
import numpy as np
from cryoem_au_data import (
HOLE_FEATURE_NAMES, compute_utility, hole_features, load_index, session_of, validate,
)
INDEX = Path("index/combined")
# 1. Does this index satisfy the contract?
validate(INDEX)
# 2. The four tables.
t = load_index(INDEX)
targets, labels = t["target_locations"], t["labels_v4_outcomes"]
print(f"\n{len(targets):,} candidate holes, {len(labels):,} acquisitions")
print("sessions:", sorted({session_of(u) for u in targets.hole_uid}))
# 3. The 13 pre-acquisition features — everything the agent knows before firing.
feats = hole_features(targets, t["square_geometry"])
print(f"\nfeatures for {len(feats):,} holes:")
print(feats[list(HOLE_FEATURE_NAMES)].describe().T[["mean", "std", "min", "max"]].round(3))
# 4. The label it is trying to maximise.
ok = labels[labels.status == "ok"]
print(f"\nutility over {len(ok):,} usable acquisitions: "
f"mean {ok.utility.mean():.1f}, sd {ok.utility.std():.1f}")
print("recompute matches shipped:",
np.allclose(compute_utility(labels), labels.utility.to_numpy(float)))
# 5. How much of the variance is between holes vs within a hole? This ratio is
# what decides whether hole choice can matter at all.
per_hole = ok.groupby("hole_uid").utility
between = per_hole.mean().std()
within = np.sqrt(per_hole.var().dropna().mean())
print(f"\nbetween-hole sd {between:.1f} vs within-hole sd {within:.1f} "
f"(ratio {between/within:.2f}) — below ~1 means holes are barely "
"distinguishable from shot noise")
|