Decision evaluation¶
Calibration estimates probabilities. Decision evaluation asks whether acting on
those estimates pays off at declared costs or capacity. These functions take
predictions from already fitted models; the existing calibrators,
select_by_cv(), and calibration_report() remain
available independently.
See Choose calibration for a decision for a complete fit, select, and test example.
- class calibre.DecisionTask(*, benefit=1.0, cost=0.0, capacity=None, fraction=None)[source]¶
Specify one payoff objective, without averaging across scenarios.
- class calibre.DecisionPolicy(*, prediction=None, rule='threshold', tie_breaker=None)[source]¶
Specify a prediction column and an outcome-blind action rule.
- Parameters:
- rule¶
Probability threshold, capacity ranking, act all, or act none.
- Type:
Literal[‘threshold’, ‘rank’, ‘all’, ‘none’]
- calibre.decision_report(y_true, predictions, *, task, policies, reference, n_resamples=2000, interval_level=0.95, random_state=0)[source]¶
Compare fixed policies on common labeled cases.
Capacity means exactly k slots (fraction rounds down), even when a selected case has negative expected payoff. Rank inputs may be arbitrary finite scores. Threshold inputs must be probabilities; equality means no action. Ties are integrated out, so intervals exclude realized lottery noise. Independent-case bootstrap resampling recomputes capacity allocations within each draw. These percentile intervals are approximate, conditional on fitting and selection, and may be unreliable for small samples or unstable ranking boundaries.
- Parameters:
y_true (ArrayLike) – Binary observed outcomes for all eligible cases.
predictions (Mapping[str, ArrayLike]) – Aligned prediction or score columns from fitted models.
task (DecisionTask) – Explicit payoff objective and optional capacity constraint.
policies (Mapping[str, DecisionPolicy]) – Nonempty mapping of names to fixed policy definitions.
reference (str) – Name of a supplied policy for paired differences.
n_resamples (int) – Bootstrap draws; zero disables intervals.
interval_level (float) – Confidence level strictly between zero and one.
random_state (int) – Nonnegative integer bootstrap seed.
- Returns:
Values and paired differences per eligible case.
- Return type:
- Raises:
ValueError – If outcomes, predictions, policies, or controls are invalid.
- calibre.select_decision_policy(y_true, predictions, *, task, policies, reference, case_ids)[source]¶
Freeze the first highest-payoff policy on validation cases.
Supply predictions from models fitted without these cases. Selection includes every supplied policy, including baselines. No model is fitted or refitted.
- Parameters:
y_true (ArrayLike) – Binary validation outcomes.
predictions (Mapping[str, ArrayLike]) – Aligned validation predictions from already fitted models.
task (DecisionTask) – Decision objective to freeze for final evaluation.
policies (Mapping[str, DecisionPolicy]) – Named candidate policies, in tie-preference order.
reference (str) – Candidate used for paired comparisons on validation and test.
case_ids (Sequence[Hashable]) – Unique nonmissing validation case identifiers.
- Returns:
Frozen specification and validation provenance.
- Return type:
- calibre.evaluate_decision_policy(selection, y_true, predictions, *, case_ids, n_resamples=2000, interval_level=0.95, random_state=0)[source]¶
Evaluate frozen candidates on disjoint test cases without reselection.
The selected policy remains
selection.selectedregardless of test ranks. ID checks detect declared validation/test overlap, not leakage during fitting or misleading identifiers. All candidate comparisons are descriptive pointwise intervals, not simultaneous coverage or permission to select again on test.- Parameters:
selection (DecisionSelection) – Frozen validation selection.
y_true (ArrayLike) – Binary test outcomes.
predictions (Mapping[str, ArrayLike]) – Test columns from the same fitted models used in selection.
case_ids (Sequence[Hashable]) – Unique nonmissing test identifiers, disjoint from validation.
n_resamples (int) – Independent-case bootstrap draws; zero disables intervals.
interval_level (float) – Confidence level strictly between zero and one.
random_state (int) – Nonnegative integer bootstrap seed.
- Returns:
Test payoffs and paired intervals with the frozen reference.
- Return type:
- Raises:
ValueError – If validation and test identifiers overlap.
- class calibre.DecisionReport(task, policies, n_observations, values, action_rates, reference, differences, intervals, interval_level, n_resamples, random_state)[source]¶
Store payoffs per eligible case and paired comparisons.
- Parameters:
task (DecisionTask)
policies (Mapping[str, DecisionPolicy])
n_observations (int)
reference (str)
interval_level (float | None)
n_resamples (int)
random_state (int)
- task¶
Objective used for every policy.
- Type:
- policies¶
Frozen policy definitions.
- Type:
Mapping[str, DecisionPolicy]
- intervals¶
Paired percentile bootstrap intervals for differences.
- class calibre.DecisionSelection(selected, validation, case_ids)[source]¶
Freeze the empirical validation winner and its evaluation specification.
- Parameters:
selected (str)
validation (DecisionReport)
case_ids (frozenset[Hashable])
- validation¶
Validation report, including all candidate policy definitions.
- Type: