Learn R Programming

measures (version 0.3)

Logloss: Logarithmic loss

Description

Defined as: -mean(log(p_i)), where p_i is the predicted probability of the true class of observation i. Inspired by https://www.kaggle.com/wiki/MultiClassLogLoss.

Usage

Logloss(probabilities, truth)

Arguments

probabilities

[numeric] vector (or matrix with column names of the classes) of predicted probabilities

truth

vector of true values

Examples

Run this code
# NOT RUN {
n = 20
set.seed(122)
truth = as.factor(sample(c(1,2,3), n, replace = TRUE))
probabilities = matrix(runif(60), 20, 3)
probabilities = probabilities/rowSums(probabilities)
colnames(probabilities) = c(1,2,3)
Logloss(probabilities, truth)
# }

Run the code above in your browser using DataLab