convex_hull_coverage¶
- probly.metrics.convex_hull_coverage = <flextype.singledispatch.Flexdispatch object>¶
Empirical convex-hull coverage for distribution-valued targets.
For each instance, the LP feasibility test
V^T lambda = t, sum(lambda) = 1, lambda in [0, 1]asks whether the target distributiontcan be expressed as a convex combination of the credal set’s vertex distributionsV. Coverage is the fraction of instances where the LP is feasible — i.e. where the target lies in the convex hull of the vertices.With
epsilon > 0the relaxed slack-variable LPV^T lambda + s+ - s- = tis solved with objectivemin sum(s+ + s-); coverage counts instances whose optimal L1 distance from the hull is at mostepsilon.Differs from
coverage()on credal sets, which takes integer class labels and uses interval dominance. This function takes wrapped distribution-valued targets and uses exact convex-hull membership.- Parameters:
y_pred – A vertex-based credal-set representation (
NumpyConvexCredalSet/NumpyDiscreteCredalSet/NumpySingletonCredalSet/TorchConvexCredalSet).y_true – A wrapped categorical distribution per instance (shape
(N, K)).NumpyCategoricalDistributionfor the numpy handlers,TorchCategoricalDistributionfor the torch handler.epsilon – L1-distance tolerance for relaxed coverage.
epsilon=0.0(the default) runs the strict feasibility LP, which is faster (no slack variables).epsilon > 0runs the slack LP.**linprog_kwargs – Forwarded to
scipy.optimize.linprog()(e.g.method="highs"or solver tolerances). Passing an unsupported kwarg raisesTypeError.
- Returns:
Fraction of instances whose target distribution lies in (or within
epsilonof) the credal set’s convex hull, asnp.float64.- Raises:
NotImplementedError – If no implementation is registered for the type of
y_pred.
Note
Only vertex-based credal sets are registered. For
NumpyProbabilityIntervalsCredalSetandTorchProbabilityIntervalsCredalSet, use the type’s owncontains()method to check whether a target distribution lies inside the (axis-aligned) credal set; that is a tighter and cheaper test than the LP feasibility check used here. Distance-based credal sets do not have explicit vertices and are intentionally not registered.TorchDirichletLevelSetCredalSetis also skipped: its envelope is estimated by Monte-Carlo sampling, which makes LP-based hull membership stochastic.