Skip to contents

Negative Log Loss for Binary

Usage

negative_log_loss_for_binary(predicted_probabilities, true_outcomes)

Arguments

predicted_probabilities

The predicted probabilities from a learner predicted at newdata.

true_outcomes

A vector of true outcomes to use in calculating the negative log loss of the relevant predicted probabilities.

Value

A sum of the negative log loss given a vector of predicted probabilities for outcome == 1 or equivalently a 'success'.

Examples

# summed negative log loss of predicted P(y = 1) against 0/1 outcomes;
# confident-and-right predictions contribute little loss ...
negative_log_loss_for_binary(c(0.9, 0.2, 0.8), c(1, 0, 1))
#> [1] 0.5516476
# ... while a confident-and-wrong prediction is penalized heavily
negative_log_loss_for_binary(c(0.05, 0.2, 0.8), c(1, 0, 1))
#> [1] 3.442019