Menu

Multi-Class Log Loss Explained: Math, MLE & Python Code
📰

Multi-Class Log Loss Explained: Math, MLE & Python Code

DEV Community: machinelearning·Malcolm Low·about 22 hours ago
#Lkvt3zBw
Reading 0:00
15s threshold

A comprehensive technical guide to Multi-Class Logarithmic Loss (Log Loss / Categorical Cross-Entropy): why lower loss indicates superior probabilistic calibration, how Maximum Likelihood Estimation requires the negative sign, why logarithms prevent floating-point underflow on large datasets, and how asymmetric penalties punish overconfident mispredictions.

1 · The Mathematical Formula & Variable Definitions

For a dataset containing N samples evaluated across C mutually exclusive classes, Multi-Class Logarithmic Loss is defined as:

$$L = -\frac{1}{N} \sum_{i=1}^N \sum_{c=1}^C y_{i,c} \ln(p_{i,c})$$

Every symbol and variable in this formulation serves a distinct mathematical role:

Symbol / Variable Domain / Value Formal Definition & Mathematical Purpose

N Positive integer Total number of observations or samples in the evaluation dataset.

C Integer $\ge 2$ Total number of discrete candidate classes in the classification task.

y_{i,c} {0, 1} Binary one-hot indicator: equals 1 if observation i belongs to…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.