Spread capped failure samples across weak contexts
GeoIntel release gates / Compile, test, contracts and builds (push) Canceled after 0s
GeoIntel release gates / Python and npm vulnerability policy (push) Canceled after 0s
GeoIntel release gates / GIS image, SBOM and container scan (push) Canceled after 0s

This commit is contained in:
Jens
2026-07-30 00:45:04 +02:00
parent 087704e326
commit c2859e5919
3 changed files with 162 additions and 8 deletions
@@ -279,6 +279,42 @@ def test_region_cap_rotates_repeats_between_sampling_rounds() -> None:
assert second_metadata["sampling_round"] == 2
def test_region_cap_preserves_failed_context_positive_before_hard_negative() -> None:
manifest = {"samples": [
{"sample_slug": "target", "split": "train", "region": "flanders", "context": "industrial"},
{"sample_slug": "negative", "split": "train", "region": "flanders", "context": "industrial-hard-negative"},
{"sample_slug": "wa", "split": "train", "region": "wallonia", "context": "rural-town"},
{"sample_slug": "br", "split": "train", "region": "brussels", "context": "dense-urban"},
]}
summary = {"tiles": [
{"sample_slug": "target", "split": "train", "label_count": 2, "image_path": "/tmp/target.png"},
{"sample_slug": "negative", "split": "train", "label_count": 0, "image_path": "/tmp/negative.png"},
{"sample_slug": "wa", "split": "train", "label_count": 1, "image_path": "/tmp/wa.png"},
{"sample_slug": "br", "split": "train", "label_count": 1, "image_path": "/tmp/br.png"},
]}
assessment = {
"status": "continue_training_loop",
"gates": {"min_region_f1": .45, "min_region_precision": .5, "min_region_recall": .4,
"max_pure_empty_false_positives": 0},
"calibration": {
"regions": {
"flanders": {"f1": .2, "precision": .2, "recall": .3},
"wallonia": {"f1": .6, "precision": .6, "recall": .6},
"brussels": {"f1": .6, "precision": .6, "recall": .6},
},
"samples": {"target": {"f1": .2, "precision": .2, "recall": .3}},
},
}
paths, metadata = MODULE.build_sampling(
summary=summary, manifest=manifest, assessment=assessment, max_region_share=.65,
)
assert paths.count(str(Path("/tmp/target.png").resolve())) == 2
assert paths.count(str(Path("/tmp/negative.png").resolve())) == 1
assert metadata["priority_positive_repeat_count"] == 4
def test_precision_guard_band_keeps_near_gate_region_stabilized() -> None:
manifest = {"samples": [
{"sample_slug": "wa-positive", "split": "train", "region": "wallonia", "context": "rural-town"},