Typed decision/classification service with an in-process gte-small ONNX embedding engine and lexical fallback, JS/Python SDKs, adapters, and the otsone model family. Apache-2.0 (sub-packages keep their MIT licenses). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
907 B
Python
32 lines
907 B
Python
"""Confidence metric tests."""
|
|
|
|
from collections.abc import Callable
|
|
|
|
import pytest
|
|
|
|
from openjev_adapters._utils.confidence_metrics import (
|
|
choice_confidence,
|
|
score_confidence,
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"confidence_metric,probabilities,expected_confidence",
|
|
[
|
|
(score_confidence, [0.2] * 5, 0.0),
|
|
(score_confidence, [0.04] * 5, 0.0),
|
|
(score_confidence, [0.01, 0.02, 0.07, 0.3, 0.6], 0.55),
|
|
(choice_confidence, [0.5, 0.5], 0.0),
|
|
(choice_confidence, [0.2, 0.2], 0.0),
|
|
(choice_confidence, [0.82, 0.18], 0.64),
|
|
(score_confidence, [1.0], 1.0),
|
|
(choice_confidence, [1.0], 1.0),
|
|
],
|
|
)
|
|
def test_confidence_metrics(
|
|
confidence_metric: Callable[[list[float]], float],
|
|
probabilities: list[float],
|
|
expected_confidence: float,
|
|
) -> None:
|
|
assert confidence_metric(probabilities) == pytest.approx(expected_confidence)
|