Skip to content

modosaic.core.score_functions

modosaic.core.score_functions

boundary_f1_score

boundary_f1_score(stats)

Extract a constraint score from boundary-alignment statistics.

Parameters:

Name Type Description Default
stats BoundaryAlignmentStats

Boundary statistics returned by a validator.

required

Returns:

Type Description
float | int

The F1 score when statistics are valid, otherwise 0.0.

Source code in modosaic/core/score_functions.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def boundary_f1_score(stats: BoundaryAlignmentStats) -> float | int:
    """Extract a constraint score from boundary-alignment statistics.

    Args:
        stats: Boundary statistics returned by a validator.

    Returns:
        The F1 score when statistics are valid, otherwise `0.0`.
    """
    if not stats.valid:
        return 0.0

    return stats.f1