Skip to content

log_loss

Module: strata.metrics • Kind: function
Source: strata/metrics/classification.mojo

def log_loss[
true_dtype: DType = DType.float64,
pred_dtype: DType = DType.float64,
](
y_true: List[Scalar[true_dtype]],
y_pred: Matrix[pred_dtype],
normalize: Bool = True,
) -> Float64
from strata.metrics import log_loss

Compute log loss (cross-entropy loss), the negative log-likelihood of true labels.

Log Loss=−1N∑i=1N∑k=1Kyi,klog⁡(pi,k)\text{Log Loss} = -\frac{1}{N} \sum_{i=1}^N \sum_{k=1}^K y_{i, k} \log(p_{i, k})

Returns: Float64 — Float64: The mean (or total) cross-entropy between y_true and y_pred.