Skip to content
Aabha AI Academy

All courses · Course overview · Lesson sequence

Skip to lesson text

practice/01_lab.py

"""Learner starter. Complete the helpers, then run check_exercise.py."""


def new_failure_ids(expected: dict[str, str], baseline: dict[str, str],
                    candidate: dict[str, str]) -> list[str]:
    """Return sorted IDs correct in baseline and incorrect in candidate.

    All three mappings must have exactly the same nonempty ID set. Raise
    ValueError when IDs are missing, extra, or empty. Values are already
    validated route strings; do not depend on mapping insertion order.
    """
    raise NotImplementedError("Implement the matched-case comparison")


def slice_accuracy(cases: list[dict], outputs: dict[str, str], slice_name: str) -> float:
    """Return route accuracy for the named slice.

    Each case has id, slice, expected_route. IDs are unique and route strings
    are validated. Outputs must match the complete case ID set, including
    other slices. Raise ValueError for incomplete/extra outputs or an empty
    named slice. Do not divide by the entire dataset size.
    """
    raise NotImplementedError("Implement the slice calculation")

Download this source file