Skip to contents

Computes the Log Score for probabilistic forecasts of binary outcomes.

Usage

logs_binary(true_values, predictions)

Arguments

true_values

A vector with the true observed values of size n with all values equal to either 0 or 1

predictions

A vector with a predicted probability that true_value = 1.

Value

A numeric value with the Log Score, i.e. the mean squared error of the given probability forecasts

Details

The Log Score is a proper score rule suited to assessing the accuracy of probabilistic binary predictions. The outcomes can be either 0 or 1, the predictions must be a probability that the true outcome will be 1.

The Log Score is then computed as the negative logarithm of the probability assigned to the true outcome. Reporting the negative logarithm means that smaller values are better.

Examples

true_values <- sample(c(0, 1), size = 30, replace = TRUE)
predictions <- runif(n = 30, min = 0, max = 1)
logs_binary(true_values, predictions)
#>  [1] 0.05031915 0.13799988 0.39599914 1.07230812 0.41369147 1.28352616
#>  [7] 1.78363640 0.03108832 0.76367311 2.95948234 1.52467055 0.06301464
#> [13] 2.15956159 1.96889558 1.08042789 0.78187048 0.82484350 0.46757583
#> [19] 0.76467049 0.60381814 0.52621322 1.03969822 1.49573701 0.79930367
#> [25] 0.36047173 0.04986037 1.28696654 0.66851740 0.33226741 0.73945793