Target regional training failures by context
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-29 17:10:19 +02:00
parent e73468318f
commit 2fd9da9e16
4 changed files with 101 additions and 3 deletions
@@ -125,3 +125,43 @@ def test_precision_correction_can_balance_positive_and_negative_tiles() -> None:
assert paths.count(str(Path("/tmp/fl-pos.png").resolve())) == 2
assert paths.count(str(Path("/tmp/fl-neg.png").resolve())) == 3
assert metadata["precision_positive_repeat"] == 2
def test_sampling_targets_failed_calibration_contexts_without_using_protected_tiles() -> None:
manifest = {
"samples": [
{"sample_slug": "train-industry", "split": "train", "region": "flanders", "context": "industrial"},
{"sample_slug": "train-suburban", "split": "train", "region": "flanders", "context": "suburban"},
{"sample_slug": "cal-industry", "split": "calibration", "region": "flanders", "context": "industrial"},
]
}
summary = {
"tiles": [
{"sample_slug": "train-industry", "split": "train", "label_count": 2, "image_path": "/tmp/industry-pos.png"},
{"sample_slug": "train-industry", "split": "train", "label_count": 0, "image_path": "/tmp/industry-neg.png"},
{"sample_slug": "train-suburban", "split": "train", "label_count": 2, "image_path": "/tmp/suburban-pos.png"},
{"sample_slug": "cal-industry", "split": "val", "label_count": 2, "image_path": "/tmp/protected.png"},
]
}
assessment = {
"status": "continue_training_loop",
"gates": {
"min_region_f1": 0.45,
"min_region_precision": 0.5,
"min_region_recall": 0.4,
"max_pure_empty_false_positives": 0,
},
"calibration": {
"regions": {"flanders": {"f1": 0.3, "precision": 0.35, "recall": 0.27}},
"samples": {"cal-industry": {"f1": 0.2, "precision": 0.3, "recall": 0.15}},
},
}
paths, metadata = MODULE.build_sampling(summary=summary, manifest=manifest, assessment=assessment)
assert paths.count(str(Path("/tmp/industry-pos.png").resolve())) == 5
assert paths.count(str(Path("/tmp/industry-neg.png").resolve())) == 6
assert paths.count(str(Path("/tmp/suburban-pos.png").resolve())) == 3
assert not any("protected" in path for path in paths)
assert metadata["weak_recall_contexts"] == ["flanders:industrial"]
assert metadata["weak_precision_contexts"] == ["flanders:industrial"]