Where you would use it
In disease screening, missing a positive case may be more costly than a false alarm, so recall and the precision–recall trade-off may matter more than raw accuracy.
Log loss is an evaluation quantity that compresses a particular aspect of predictive behaviour into a number. Its usefulness depends on whether that aspect matches the real decision cost, class prevalence and intended model output.
Log loss is an evaluation quantity that compresses a particular aspect of predictive behaviour into a number. Its usefulness depends on whether that aspect matches the real decision cost, class prevalence and intended model output.
The practical value of Log loss comes from understanding both the transformation and the boundary around it: what information is allowed to enter, what assumption is being made, and how you know the result is still valid after the transformation.
A beginner-friendly way to reason about it is to start with a tiny case where the correct result can be checked independently. Once the mechanism is clear, scale the exact same reasoning to larger tables, pipelines or models.
Compute predictions on data not used to fit the model, derive the metric from labels/scores/probabilities as appropriate, and inspect uncertainty and relevant subgroups instead of reading one number in isolation.
The interactive view uses a concept-specific plot when the topic maps naturally to one; otherwise it uses a workflow view instead of leaving a broken placeholder.
In disease screening, missing a positive case may be more costly than a false alarm, so recall and the precision–recall trade-off may matter more than raw accuracy.
A useful diagnostic question is: Could the same code still run successfully if the analytical assumption were wrong? If yes, add an explicit validation check rather than relying on execution success.
Keep the example small enough that you can inspect each stage manually.
# Step 1 — Import only the named objects needed by the following steps, keeping dependencies explicit.
from sklearn.metrics import log_loss
# Step 2 — Compute the right-hand expression and store its result in `y_true` for the next step.
y_true = [0,0,1,1,1,0]
# Step 3 — Compute the right-hand expression and store its result in `prob` for the next step.
prob = [0.10,0.25,0.70,0.85,0.60,0.30]
# Step 4 — Display the current value explicitly so the result/state can be inspected during execution.
print("STEP 1 · observations:", len(y_true))
# Step 5 — Display the current value explicitly so the result/state can be inspected during execution.
print("STEP 2 · probability range:", min(prob), max(prob))
# Step 6 — Display the current value explicitly so the result/state can be inspected during execution.
print("STEP 3 · log loss:", round(log_loss(y_true, prob), 3))STEP 1 · observations: 6 STEP 2 · probability range: 0.1 0.85 STEP 3 · log loss: 0.297