Skip to content

Commit 724da85

Browse files
committed
test(ml): add threshold monotonicity coverage for is_flagged
1 parent deb83c7 commit 724da85

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# path: policylens/tests/test_ml_threshold_monotonicity.py
2+
"""
3+
Tests for threshold monotonicity.
4+
"""
5+
6+
from __future__ import annotations
7+
8+
from policylens.apps.claims.ml.thresholds import is_flagged
9+
10+
11+
def test_threshold_monotonicity_holds_for_increasing_scores():
12+
"""If score increases, flagged status must not flip from True to False."""
13+
threshold = 0.6
14+
scores = [0.0, 0.2, 0.59, 0.6, 0.61, 0.9, 1.0]
15+
16+
flagged = [is_flagged(score=s, threshold=threshold) for s in scores]
17+
18+
# Once flagged becomes True, it must stay True for higher scores.
19+
seen_true = False
20+
for f in flagged:
21+
if f:
22+
seen_true = True
23+
if seen_true:
24+
assert f is True

0 commit comments

Comments
 (0)