View source: R/classif_logloss.R
logloss | R Documentation |
Measure to compare true observed labels with predicted probabilities in multiclass classification tasks.
logloss(truth, prob, sample_weights = NULL, eps = 1e-15, ...)
truth |
( |
prob |
( |
sample_weights |
( |
eps |
( |
... |
( |
The Log Loss (a.k.a Benoulli Loss, Logistic Loss, Cross-Entropy 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
and w_i
are normalized weights for each observation x_i
.
Performance value as numeric(1)
.
Type: "classif"
Range: [0, \infty)
Minimize: TRUE
Required prediction: prob
Other Classification Measures:
acc()
,
bacc()
,
ce()
,
mauc_aunu()
,
mbrier()
,
mcc()
,
zero_one()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.