scoring_rules#

A collection of scoring rules for Bayes risk minimization with ScoringRuleNetwork.

Examples#

>>> # A network to estimate both point estimates and parameters of a multivariate normal distribution.
>>> from bayesflow.scoring_rules import MeanScore, QuantileScore, MvNormalScore
>>> inference_network = bf.networks.ScoringRuleNetwork(
...     mean=MeanScore(),
...     quantiles=QuantileScore(),
...     mvn=MvNormalScore(),
... )

Inherit from ScoringRule to build your own custom scoring rule.

Classes

CrossEntropyScore(**kwargs)

Categorical cross-entropy scoring rule for classification tasks.

MeanScore(**kwargs)

\(S(\hat \theta, \theta) = | \hat \theta - \theta |^2\)

MedianScore(**kwargs)

\(S(\hat \theta, \theta) = | \hat \theta - \theta |\)

MvNormalScore([dim, links])

\(S(\hat p_{\mu, \Sigma}, \theta; k) = -\log( \mathcal N (\theta; \mu, \Sigma))\)

NormedDifferenceScore(k, **kwargs)

\(S(\hat \theta, \theta; k) = | \hat \theta - \theta |^k\)

ParametricDistributionScore(**kwargs)

\(S(\hat p_\phi, \theta; k) = -\log(\hat p_\phi(\theta))\)

QuantileScore([q, links])

\(S(\hat \theta_i, \theta; \tau_i) = (\hat \theta_i - \theta)(\mathbf{1}_{\hat \theta - \theta > 0} - \tau_i)\)

ScoringRule([subnets, subnets_kwargs, links])

Base class for scoring rules.