SampleMeanConvexCredalSetRepresenter

class probly.representer.credal_set.SampleMeanConvexCredalSetRepresenter(predictor: EnsemblePredictor[In, Out], num_samples: int = 20)[source]

Bases: ConvexCredalSetRepresenter[In, Out, C], Generic[In, Out, C]

Build a convex credal set whose vertices are sample means of stochastic ensemble members.

Wraps each member of an iterable predictor in a Sampler that draws num_samples Monte Carlo predictions and averages them into a single representation per member. The resulting M averaged representations form the vertices of a convex credal set.

This representer is appropriate when each ensemble member is a stochastic predictor (such as a Bayesian neural network trained with mean-field variational inference) and the desired credal-set vertex is the predictive mean over each member’s stochastic posterior.

Initialize the representer.

Parameters:
  • predictor – The ensemble predictor whose members are stochastic predictors.

  • num_samples – The number of Monte Carlo samples drawn per ensemble member before averaging.

__call__(*args: In.args, **kwargs: In.kwargs) R[source]

Alias for the represent method.

num_samples: int
predict(*args: In.args, **kwargs: In.kwargs) R[source]

Predict the representation for a given input.

predictor
represent(*args: In.args, **kwargs: In.kwargs) C[source]

Build a convex credal set for the given input.

sub_samplers: list[Sampler]