Log Loss Calculator
Binary logarithmic loss from labels and probabilities.
About this tool
Enter the true 0/1 labels and your model's predicted probabilities for class 1, and get the binary log loss. It punishes confident wrong predictions heavily. Lower is better; 0 is perfect.
How to use
How it works
Log loss = −(1/n) Σ [y·ln(p) + (1 − y)·ln(1 − p)] with natural logs. A correct prediction at p = 0.9 costs 0.105; a wrong one at p = 0.9 costs 2.30. Predicting 0.5 for everything gives 0.693.
−(1/n) Σ [ y·ln p + (1 − y)·ln(1 − p) ]
Worked example
Four predictions
- Input
- Labels: 1, 0, 1, 1 Probabilities: 0.9, 0.1, 0.8, 0.7
- Output
- Log loss 0.197635 (n = 4)
- Walkthrough
- The per-example losses are −ln 0.9 = 0.105, −ln 0.9 = 0.105, −ln 0.8 = 0.223 and −ln 0.7 = 0.357. Their average is 0.1976.
Limitations
- Binary labels only; for several classes use cross-entropy.
- Probabilities are clipped away from exactly 0 and 1, so a fully confident wrong prediction costs about 34.5 instead of infinity, and one of those can dominate the average.
- Uses natural logarithms (nats).
Questions
How do I calculate log loss?
What is a good log loss?
Log loss vs accuracy?
Is log loss the same as cross-entropy?
Features
- Binary cross-entropy
- Natural log
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
Machine Learning for Everybody
freeCodeCamp.org
Accessible ML survey for AI calculator and metric tools.
Watch on YouTubeVectors | Essence of linear algebra
3Blue1Brown
Embeddings and vectors start with linear algebra intuition.
Watch on YouTube
- DeepLearning.AI
DeepLearning.AI
Courses and explainers for modern AI tooling.
- Hugging Face docs
Hugging Face
Model hub docs next to tokenizer and embedding helpers.