Skip to main content

LogLoss

Metric
DashAI.back.metrics.classification.LogLoss

Negative log-likelihood of true labels under the predicted probability distribution.

Log Loss (cross-entropy loss) penalises confident wrong predictions much more heavily than uncertain ones. Unlike accuracy or F1, it evaluates the full probability output of the classifier rather than just the argmax label, rewarding well-calibrated models.

Lower values indicate better performance (MAXIMIZE = False). A perfect classifier achieves log loss of 0; a random classifier on a binary problem achieves approximately ln(2) ≈ 0.693.

::

Log Loss = -(1/N) · Σᵢ Σ_c yᵢ_c · log(pᵢ_c)

where yᵢ_c is 1 if sample i belongs to class c and pᵢ_c is the predicted probability.

Range: [0, +∞), lower is better (MAXIMIZE = False).

References

Methods

score(true_labels: 'DashAIDataset', probs_pred_labels: 'np.ndarray', multiclass: Optional[bool] = None) -> float

Defined on LogLoss

Calculate Log Loss score between true labels and predicted labels.

Parameters

true_labels : DashAIDataset
A DashAI dataset with labels.
probs_pred_labels : np.ndarray
A two-dimensional matrix in which each column represents a class and the row values represent the probability that an example belongs to the class associated with the column.
multiclass : bool, optional
Whether the task is a multiclass classification. If None, it will be determined automatically from the number of unique labels.

Returns

float
Log Loss score between true labels and predicted labels

get_metadata(cls: 'BaseMetric') -> Dict[str, Any]

Defined on BaseMetric

Get metadata values for the current metric.

Returns

Dict[str, Any]
Dictionary with the metadata

is_multiclass(true_labels: 'np.ndarray') -> bool

Defined on ClassificationMetric

Determine if the classification problem is multiclass (more than 2 classes).

Parameters

true_labels : np.ndarray
Array of true labels.

Returns

bool
True if the problem has more than 2 unique classes, False otherwise.

Compatible with