View source: R/quant-weighted_interval_score.R
| weighted_interval_score | R Documentation |
Weighted interval score (WIS), a well-known quantile-based approximation of the commonly-used continuous ranked probability score (CRPS). WIS is a proper score, and can be thought of as a distributional generalization of absolute error. For example, see Bracher et al. (2020) for discussion in the context of COVID-19 forecasting.
weighted_interval_score(data, ...)
## S3 method for class 'data.frame'
weighted_interval_score(
data,
truth,
estimate,
quantile_levels = NULL,
na_rm = TRUE,
quantile_estimate_nas = c("impute", "drop", "propagate"),
case_weights = NULL,
...
)
weighted_interval_score_vec(
truth,
estimate,
quantile_levels = NULL,
na_rm = FALSE,
quantile_estimate_nas = c("impute", "drop", "propagate"),
case_weights = NULL,
...
)
data |
A |
... |
Not Currently used. |
truth |
The column identifier for the true class results
(that is a |
estimate |
The column identifier for the predicted class results
(that is also |
quantile_levels |
probabilities. If specified, the score will be
computed at this set of levels. Otherwise, those present in |
na_rm |
logical. If |
quantile_estimate_nas |
character. This argument applies only to
|
case_weights |
The optional column identifier for case weights. This
should be an unquoted column name that evaluates to a numeric column in
|
Weighted interval score is a metric that should be minimized. The output ranges from 0 to Inf, with 0 indicating perfect predictions.
a vector of nonnegative scores.
All quantile metrics
library(hardhat)
quantile_levels <- c(.2, .4, .6, .8)
pred1 <- 1:4
pred2 <- 8:11
preds <- quantile_pred(rbind(pred1, pred2), quantile_levels)
truth <- c(3.3, 7.1)
weighted_interval_score_vec(truth, preds)
weighted_interval_score_vec(truth, preds, quantile_levels = c(.25, .5, .75))
# Missing value behaviours
preds_na <- quantile_pred(rbind(pred1, c(1, 2, NA, 4)), 1:4 / 5)
truth <- c(2.5, 2.5)
weighted_interval_score_vec(truth, preds_na)
weighted_interval_score_vec(truth, preds_na, quantile_levels = 1:9 / 10)
try(weighted_interval_score_vec(
truth,
preds_na,
quantile_levels = 1:9 / 10,
quantile_estimate_nas = "drop"
))
weighted_interval_score_vec(
truth,
preds_na,
quantile_levels = c(2, 3) / 5,
quantile_estimate_nas = "drop"
)
weighted_interval_score_vec(
truth, preds_na, na_rm = TRUE, quantile_estimate_nas = "propagate"
)
weighted_interval_score_vec(
truth, preds_na, quantile_estimate_nas = "propagate"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.