Log loss, aka logistic loss or cross-entropy loss.
This is the loss function used in (multinomial) logistic regression
and extensions of it such as neural networks, defined as the negative
log-likelihood of a logistic model that returns probabilities
for its training data .
The log loss is only defined for two or more labels.
For a single sample with true label and
a probability estimate , the log
loss is:
Ground truth (correct) labels for n_samples samples.
y_proba : array-like of float, shape = (n_samples, n_classes) or (n_samples,)
Predicted probabilities, as returned by a classifier’s
predict_proba method. If y_proba.shape=(n_samples,)
the probabilities provided are assumed to be that of the
positive class. The labels in y_proba are assumed to be
ordered alphabetically, as done by
LabelBinarizer.
y_proba values are clipped to [eps,1-eps] where eps is the machine
precision for y_proba’s dtype.
normalize : bool, default=True
If true, return the mean loss per sample.
Otherwise, return the sum of the per-sample losses.
sample_weight : array-like of shape (n_samples,), default=None
Sample weights.
labels : array-like, default=None
If not provided, labels will be inferred from y_true. If labels
is None and y_pred has shape (n_samples,) the labels are
assumed to be binary and are inferred from y_true.
y_pred : array-like of float, shape = (n_samples, n_classes) or (n_samples,)
Predicted probabilities, as returned by a classifier’s
predict_proba method. If y_pred.shape=(n_samples,)
the probabilities provided are assumed to be that of the
positive class. The labels in y_pred are assumed to be
ordered alphabetically, as done by
LabelBinarizer.
y_pred values are clipped to [eps,1-eps] where eps is the machine
precision for y_pred’s dtype.
Returns:
loss : float
Log loss, aka logistic loss or cross-entropy loss.
Notes
The logarithm used is the natural logarithm (base-e).