Negative Log Loss
Arguments
- predicted_densities
The predicted densities from a learner predicted at
newdata.- ...
Because
nadir::compare_learners()passesestimates, truthto theloss_metricpassed to it,negative_log_lossaccepts ... but doesn't do anything with it.
Value
A sum of the negative log loss given a vector of predicted probabilities/densities for some observed outcome.
Details
negative_log_loss encodes the logic:
if \(\hat p_n\) is a good model of the conditional densities, then it should minimize:
$$ -\sum(\log(\hat p_n(X_i)) $$
Examples
# suppose we have some prediction probabilities _at the true values_:
predicted_probabilities <- lnr_logistic(mtcars, am ~ hp)(mtcars)
# we can calculate the -log(loss) for binary predicted probabilities like so:
negative_log_loss(predicted_probabilities)
#> [1] 30.57476
