Estimand aggregators and exact estimation¶
Exact coalition enumeration estimator.
- class nlp_shap.estimation.exact.ExactEstimator[source]¶
Bases:
objectEnumerate all coalitions and delegate attribution to an estimand plugin.
- static num_coalitions(num_players: int) int[source]¶
Return the number of coalitions evaluated by exact enumeration.
- static iter_mask_ints(num_players: int) Iterator[int][source]¶
Lazily yield coalition bitmasks except the all-present coalition.
- static mask_int_to_present(mask_int: int, num_players: int) tuple[bool, ...][source]¶
Decode a coalition bitmask into presence flags.
- bind_snapshot(snapshot: ConversationSnapshot) None[source]¶
Attach the conversation snapshot under explanation.
- sample_masks(player_set: PlayerSet, budget_fraction: float, include_minimal_masks: bool, seed: int) Iterator[CoalitionMask][source]¶
Yield every coalition mask except the grand coalition.
- static iter_masks(player_set: PlayerSet) Iterator[CoalitionMask][source]¶
Lazily yield coalition masks except the all-present coalition.
- estimate_attributions(masks: Sequence[CoalitionMask], payoffs: Sequence[float], aggregator: EstimandAggregator) list[float][source]¶
Aggregate coalition payoffs with the selected estimand plugin.
Shapley estimand aggregation.
- class nlp_shap.estimation.estimands.shapley.ShapleyAggregator[source]¶
Bases:
objectAggregate coalition samples with Shapley coalition weights.
Banzhaf estimand aggregation.