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 distribution t can be expressed as a convex combination of the credal set’s vertex distributions V. 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 > 0 the relaxed slack-variable LP V^T lambda + s+ - s- = t is solved with objective min sum(s+ + s-); coverage counts instances whose optimal L1 distance from the hull is at most epsilon.

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)). NumpyCategoricalDistribution for the numpy handlers, TorchCategoricalDistribution for 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 > 0 runs the slack LP.

  • **linprog_kwargs – Forwarded to scipy.optimize.linprog() (e.g. method="highs" or solver tolerances). Passing an unsupported kwarg raises TypeError.

Returns:

Fraction of instances whose target distribution lies in (or within epsilon of) the credal set’s convex hull, as np.float64.

Raises:

NotImplementedError – If no implementation is registered for the type of y_pred.

Note

Only vertex-based credal sets are registered. For NumpyProbabilityIntervalsCredalSet and TorchProbabilityIntervalsCredalSet, use the type’s own contains() 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. TorchDirichletLevelSetCredalSet is also skipped: its envelope is estimated by Monte-Carlo sampling, which makes LP-based hull membership stochastic.