scoringrules.weighted_interval_score#
- scoringrules.weighted_interval_score(obs: ArrayLike, median: Array, lower: Array, upper: Array, alpha: Array, w_median: float | None = None, w_alpha: Array | None = None, *, backend: Backend = None) Array#
Compute the weighted interval score (WIS).
The WIS [(Bracher et al., 2022)](https://doi.org/10.1371/journal.pcbi.1008618) is defined as
\[\text{WIS}_{\alpha_{0:K}}(F, y) = \frac{1}{K+0.5}(w_0 \times |y - m| + \sum_{k=1}^K (w_k \times IS_{\alpha_k}(F, y)))\]where \(m\) denotes the median prediction, \(w_0\) denotes the weight of the median prediction, \(IS_{\alpha_k}(F, y)\) denotes the interval score for the \(1 - \alpha\) prediction interval and \(w_k\) is the according weight. The WIS is calculated for a set of (central) PIs and the predictive median. The weights are an optional parameter and default weight is the canonical weight \(w_k = \frac{2}{\alpha_k}\) and \(w_0 = 0.5\). For these weights, it holds that:
\[\text{WIS}_{\alpha_{0:K}}(F, y) \approx \text{CRPS}(F, y).\]- Parameters:
- obsarray_like
The observations as a scalar or array of shape (…,).
- medianarray_like
The predicted median of the distribution as a scalar or array of shape (…,).
- lowerarray_like
The predicted lower bound of the PI. If alpha is an array of shape (K,), lower must have shape (…,K).
- upperarray_like
The predicted upper bound of the PI. If alpha is an array of shape (K,), upper must have shape (…,K).
- alphaarray_like
The 1 - alpha level for the prediction intervals as an array of shape (K,).
- w_medianfloat
The weight for the median prediction. Defaults to 0.5.
- w_alphaarray_like
The weights for the PI. Defaults to 2/alpha.
- backendstr
The name of the backend used for computations. Defaults to ‘numba’ if available, else ‘numpy’.
- Returns:
- score:
An array of interval scores with the same shape as obs.