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
>>> import bayesflow as bf
>>> inference_network = bf.networks.ScoringRuleNetwork(
... mean=MeanScore(),
... quantiles=QuantileScore(),
... mvn=MvNormalScore(),
... )
>>> # A network to estimate posterior model probabilities with multiple categorical scoring rules.
>>> from bayesflow.scoring_rules import (
... CrossEntropyScore,
... BrierScore,
... PolynomialScore,
... ExponentialScore,
... LogisticScore,
... )
>>> comparison_network = bf.networks.ScoringRuleNetwork(
... cross_entropy=CrossEntropyScore(),
... brier=BrierScore(),
... polynomial=PolynomialScore(alpha=2.0),
... exponential=ExponentialScore(links={"logits": bf.links.Leaky(power=2.0)}),
... logistic=LogisticScore(),
... power_logistic=LogisticScore(alpha=1.0),
... )
Inherit from ScoringRule to build your own custom scoring rule.
Classes
|
\(S(\hat p_{1\ldots C}, y) = \sum_{c=1}^C (\hat p_c - y_c)^2\) |
|
Base class for scoring rules over categorical (one-hot encoded) targets. |
|
\(S(\hat p_{1\ldots C}, y) = -\sum_{c=1}^C y_c \log \hat p_c\) |
|
\(S(\{f_k\}, m) = \sum_{k \neq m} \exp\!\left(\tfrac{1}{2}(f_k - f_m)\right)\) |
|
\(S(\{f_k\}, m; \alpha) = \sum_{k \neq m} \left(1 + e^{(f_k - f_m)/(\alpha+1)}\right)^\alpha\) for \(\alpha > 0\), and its \(\alpha \to 0\) limit |
|
\(S(\hat \theta, \theta) = | \hat \theta - \theta |^2\) |
|
\(S(\hat \theta, \theta) = | \hat \theta - \theta |\) |
|
\(S(\hat p_{\phi_{1\ldots K},w_{1\ldots K}},\theta)=-\sum_{k=1}^{K} \log w_k+\log(\hat p_{\phi_k}(\theta))\) |
|
\(S(\hat p_{\mu, \Sigma}, \theta; k) = -\log( \mathcal N (\theta; \mu, \Sigma))\) |
|
\(S(\hat \theta, \theta; k) = | \hat \theta - \theta |^k\) |
|
\(S(\hat p_\phi, \theta; k) = -\log(\hat p_\phi(\theta))\) |
|
\(S(\hat p_{1\ldots C}, y; \alpha) = \tfrac{\alpha-1}{\alpha}\sum_c \hat p_c^\alpha - \hat p_y^{\alpha-1}\) |
|
\(S(\hat \theta_i, \theta; \tau_i) = (\hat \theta_i - \theta)(\mathbf{1}_{\hat \theta - \theta > 0} - \tau_i)\) |
|
Base class for scoring rules. |