Decision Making¶
online_cp.decision.UtilityFunction
¶
Utility function bundled with its decision space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
callable
|
A function |
required |
decisions
|
sequence
|
The set of available decisions (the decision space D). |
required |
Examples:
>>> utility = UtilityFunction(lambda x, y, d: -(y - d)**2,
... decisions=[0.0, 0.5, 1.0, 1.5, 2.0])
>>> utility(None, 1.0, 1.0)
0.0
Source code in src/online_cp/decision.py
online_cp.decision.cps_expected_utilities(cpd, utility: UtilityFunction, x: Any, tau: float = 0.5) -> dict[Any, float]
¶
Compute expected utility under a CPD for each decision (Vovk & Bendtsen 2018).
For each decision d in utility.decisions, computes:
.. math::
E_\tau[U(x, \cdot, d)] = \sum_j U(x, C_j, d) \, \Delta Q_\tau(C_j)
where :math:\Delta Q_\tau(C_j) is the probability mass at critical
point :math:C_j under randomisation parameter :math:\tau.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cpd
|
ConformalPredictiveDistributionFunction
|
A conformal predictive distribution object with attributes |
required |
utility
|
UtilityFunction
|
Utility function with decision space. |
required |
x
|
any
|
Features of the test object (passed to utility). |
required |
tau
|
float
|
Randomisation parameter in [0, 1]. |
0.5
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping from each decision to its expected utility (float). |
Source code in src/online_cp/decision.py
online_cp.decision.cps_decision(cpd, utility: UtilityFunction, x: Any, tau: float = 0.5) -> Any
¶
Select optimal decision by maximising expected utility under a label-CPD.
This is the naive approach: a single CPD is trained on raw labels, and expected utility is computed by weighting U(x, C_j, d) by the CPD masses. Practical for large or continuous decision spaces.
For the exact Vovk & Bendtsen (2018) Algorithm 1 (one CPD per decision,
trained on utility-transformed labels), use
:class:ConformalPredictiveDecisionMaker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cpd
|
ConformalPredictiveDistributionFunction
|
Conformal predictive distribution. |
required |
utility
|
UtilityFunction
|
Utility function with decision space. |
required |
x
|
any
|
Features of the test object. |
required |
tau
|
float
|
Randomisation parameter. |
0.5
|
Returns:
| Type | Description |
|---|---|
any
|
The optimal decision. |
Source code in src/online_cp/decision.py
online_cp.decision.venn_expected_utilities(venn_pred, utility: UtilityFunction, x: Any) -> dict[Any, NDArray[np.floating]]
¶
Compute expected utility under each Venn hypothesis for each decision.
For each decision d and hypothesis v:
.. math::
E_{P^v}[U(x, \cdot, d)] = \sum_j P^v(\text{label}_j) \, U(x, \text{label}_j, d)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venn_pred
|
VennPrediction
|
Multiprobability prediction with |
required |
utility
|
UtilityFunction
|
Utility function with decision space. |
required |
x
|
any
|
Features of the test object (passed to utility). |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Mapping from each decision to an ndarray of shape (|Y|,) giving the expected utility under each hypothesis. |
Source code in src/online_cp/decision.py
online_cp.decision.venn_decision(venn_pred, utility: UtilityFunction, x: Any, criterion: str = 'utility', alpha: float = 0.0) -> Any
¶
Select optimal decision under Venn multiprobability (Venn-PDMS).
Computes expected utilities under each Venn hypothesis, then applies one of two decision criterion families:
"utility"(α-utility): score(d) = α·upper + (1−α)·lower. α=0 is maximin, α=1 is maximax, α=0.5 is midpoint."regret"(α-regret): minimise the α-weighted regret. α=0 is minimax regret, α=1 is minimin regret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venn_pred
|
VennPrediction
|
Multiprobability prediction. |
required |
utility
|
UtilityFunction
|
Utility function with decision space. |
required |
x
|
any
|
Features of the test object. |
required |
criterion
|
str
|
One of |
"utility"
|
alpha
|
float
|
Optimism index in [0, 1]. α=0 is pessimistic (default). |
0.0
|
Returns:
| Type | Description |
|---|---|
any
|
The optimal decision. |
Source code in src/online_cp/decision.py
online_cp.decision.alpha_utility(expectations: dict[Any, float | NDArray | tuple], alpha: float = 0.0) -> Any
¶
α-utility criterion: Hurwicz-weighted expected utility.
For each decision d, the score is:
score(d) = α · upper(E[U|d]) + (1 − α) · lower(E[U|d])
Special cases:
- α = 0: maximin (pessimistic — maximise worst-case utility)
- α = 1: maximax (optimistic — maximise best-case utility)
- α = 0.5: midpoint (average of best/worst case)
When expectations are scalars (point case), all α values give the same result (maximize).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expectations
|
dict
|
Mapping from decision to expected utility. Values can be: scalars (point), ndarrays (one per hypothesis), or tuples (lo, hi). |
required |
alpha
|
float
|
Optimism index (0 = pessimistic, 1 = optimistic). |
0.0
|
Returns:
| Type | Description |
|---|---|
any
|
The optimal decision. |
Source code in src/online_cp/decision.py
online_cp.decision.alpha_regret(expectations: dict[Any, NDArray | tuple], alpha: float = 0.0) -> Any
¶
α-regret criterion: Hurwicz-weighted regret minimisation.
For each scenario/hypothesis v, the regret of decision d is
max_{d'} E_v[U(d')] - E_v[U(d)]. The score for each decision is:
score(d) = α · min_v R_v(d) + (1 − α) · max_v R_v(d)
We select the decision minimising this score.
Special cases:
- α = 0: minimax regret (pessimistic — minimise worst-case regret)
- α = 1: minimin regret (optimistic — minimise best-case regret)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expectations
|
dict
|
Mapping from decision to imprecise expectations (ndarray or tuple). |
required |
alpha
|
float
|
Optimism index (0 = pessimistic, 1 = optimistic). |
0.0
|
Returns:
| Type | Description |
|---|---|
any
|
The decision minimising the α-regret score. |