Fineweb-Classifier-Marketing / scoring_utils.py
Nadav-marketaem's picture
Add training and inference code
07e8637
Raw
History Blame Contribute Delete
447 Bytes
"""
Shared score-rounding helper.
Used by both annotation/annotate.py (Stage 2 aggregation) and
classification/infer.py (Stage 4 inference) to compute the `int_score`
column: round(clip(score, 0, 5)) -> integer 0-5, for FineWeb-EDU
backwards compatibility.
"""
def clip_round_score(score: float) -> int:
"""round(clip(score, 0, 5)) -> integer 0-5. Uses Python's banker's rounding."""
return int(round(max(0.0, min(5.0, float(score)))))