Balance positives during precision correction
This commit is contained in:
@@ -91,3 +91,37 @@ def test_sampling_can_use_calibration_before_test_is_opened() -> None:
|
||||
)
|
||||
assert len(paths) == 3
|
||||
assert metadata["failure_evidence_source"] == "calibration"
|
||||
|
||||
|
||||
def test_precision_correction_can_balance_positive_and_negative_tiles() -> None:
|
||||
manifest = {"samples": [{"sample_slug": "train-fl", "split": "train", "region": "flanders"}]}
|
||||
summary = {
|
||||
"tiles": [
|
||||
{"sample_slug": "train-fl", "split": "train", "label_count": 2, "image_path": "/tmp/fl-pos.png"},
|
||||
{"sample_slug": "train-fl", "split": "train", "label_count": 0, "image_path": "/tmp/fl-neg.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.46, "precision": 0.45, "recall": 0.46}}
|
||||
},
|
||||
}
|
||||
|
||||
paths, metadata = MODULE.build_sampling(
|
||||
summary=summary,
|
||||
manifest=manifest,
|
||||
assessment=assessment,
|
||||
precision_positive_repeat=2,
|
||||
negative_repeat=3,
|
||||
)
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user