Source code for nlp_shap.protocols.estimand

"""Estimand aggregation protocol."""

from collections.abc import Sequence
from typing import Protocol

from ..domain.estimands import Estimand


[docs] class EstimandAggregator(Protocol): """Aggregate coalition payoffs into per-player attributions.""" @property def estimand(self) -> Estimand: """Return the estimand label produced by this aggregator."""
[docs] def coalition_weight(self, coalition_size: int, num_players: int) -> float: """Return coalition weight for the given size excluding the focal player."""
[docs] def aggregate( self, masks: Sequence[Sequence[bool]], payoffs: Sequence[float], ) -> list[float]: """Aggregate coalition samples into per-player attribution values."""