Measure to compare true observed labels with predicted probabilities in multiclass classification tasks.
Arguments
- truth
(
factor()
)
True (observed) labels. Must have the same levels and length asresponse
.- prob
(
matrix()
)
Matrix of predicted probabilities, each column is a vector of probabilities for a specific class label. Columns must be named with levels oftruth
.- sample_weights
(
numeric()
)
Vector of non-negative and finite sample weights. Must have the same length astruth
. The vector gets automatically normalized to sum to one. Defaults to equal sample weights.- eps
(
numeric(1)
)
Probabilities are clipped tomax(eps, min(1 - eps, p))
. Otherwise the measure would be undefined for probabilitiesp = 0
andp = 1
.- ...
(
any
)
Additional arguments. Currently ignored.
Details
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\).