scoringrules.rls_score

Contents

scoringrules.rls_score#

scoringrules.rls_score(obs: ArrayLike, fct: ArrayLike, k_axis: int = -1, *, onehot: bool = False, backend: Backend = None) Array#

Compute the (Discrete) Ranked Logarithmic Score (RLS).

Suppose the outcome corresponds to one of \(K\) ordered categories. The RLS is defined as

\[RPS(f, y) = -\sum_{k=1}^{K} \log|\tilde{f}_{k} + \tilde{y}_{k} - 1|,\]

where \(f \in [0, 1]^{K}\) is a vector of length \(K\) containing forecast probabilities that each of the \(K\) categories will occur, and \(y \in \{0, 1\}^{K}\) is a vector of length \(K\), with the \(k\)-th element equal to one if the \(k\)-th category occurs. We have \(\sum_{k=1}^{K} y_{k} = \sum_{k=1}^{K} f_{k} = 1\), and, for \(k = 1, \dots, K\), \(\tilde{y}_{k} = \sum_{i=1}^{k} y_{i}\) and \(\tilde{f}_{k} = \sum_{i=1}^{k} f_{i}\).

Parameters:
obsarray_like

Observed outcome, either 0 or 1.

fctarray_like

Forecasted probabilities between 0 and 1.

k_axis: int

The axis corresponding to the categories. Default is the last axis.

onehot: bool

Boolean indicating whether the observation is the category that occurs or a onehot encoded vector of 0’s and 1’s. Default is False.

backendstr

The name of the backend used for computations. Defaults to ‘numpy’.

Returns:
scorearray_like

The computed Ranked Logarithmic Score.