mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-03 11:32:59 +08:00
fix: restore recency weighting in compute_mastery (#618)
This commit is contained in:
@@ -31,7 +31,7 @@ def compute_mastery(correctness: list[bool]) -> float:
|
||||
return 0.0
|
||||
recent = correctness[-len(_RECENCY_WEIGHTS) :]
|
||||
weights = _RECENCY_WEIGHTS[-len(recent) :]
|
||||
score = sum(w * (1.0 if c else 0.0) for w, c in zip(recent, weights, strict=True)) / sum(
|
||||
score = sum(w * (1.0 if c else 0.0) for c, w in zip(recent, weights, strict=True)) / sum(
|
||||
weights
|
||||
)
|
||||
return min(score, _CONFIDENCE_CAP.get(len(recent), 1.0))
|
||||
|
||||
@@ -69,6 +69,18 @@ def test_compute_mastery_partial_correctness_scales():
|
||||
assert one_of_five < two_of_five < three_of_five
|
||||
|
||||
|
||||
def test_compute_mastery_weighs_recent_attempts_more_heavily():
|
||||
"""Regression test for #618: recency weighting must actually distinguish
|
||||
a recovering history from a declining one, even with the same correct
|
||||
count. A miss-then-two-hits history should score higher than a
|
||||
two-hits-then-miss history."""
|
||||
recovering = compute_mastery([False, True, True])
|
||||
declining = compute_mastery([True, True, False])
|
||||
assert recovering > declining
|
||||
assert recovering == pytest.approx(0.696, abs=1e-3)
|
||||
assert declining == pytest.approx(0.643, abs=1e-3)
|
||||
|
||||
|
||||
# ── grade_and_record: the unified post-answer pipeline ─────────────────────
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user