logloss {mlr3measures} | R Documentation |
Log Loss
Description
Measure to compare true observed labels with predicted probabilities in multiclass classification tasks.
Usage
logloss(truth, prob, sample_weights = NULL, eps = 1e-15, ...)
Arguments
truth |
( |
prob |
( |
sample_weights |
( |
eps |
( |
... |
( |
Details
The Log Loss is defined as
-\frac{1}{n} \sum_{i=1}^n w_i \log \left( p_i \right )
where p_i
is the probability for the true class of observation i
.
Value
Performance value as numeric(1)
.
Meta Information
Type:
"classif"
Range:
[0, \infty)
Minimize:
TRUE
Required prediction:
prob
See Also
Other Classification Measures:
acc()
,
bacc()
,
ce()
,
mauc_aunu()
,
mbrier()
,
mcc()
,
zero_one()
Examples
set.seed(1)
lvls = c("a", "b", "c")
truth = factor(sample(lvls, 10, replace = TRUE), levels = lvls)
prob = matrix(runif(3 * 10), ncol = 3, dimnames = list(NULL, lvls))
prob = t(apply(prob, 1, function(x) x / sum(x)))
logloss(truth, prob)