PythiloLesson 5 of 12 · progress kept in this browser

Practice in Lab: Measure probability error instead of only decisions →

Measure probability error instead of only decisions

Two classifiers can make identical binary decisions while assigning very different probabilities. Brier score measures the mean squared difference between each predicted positive probability and its binary outcome. It is sensitive to probability quality, while thresholded accuracy discards that information.

The score alone does not separate reliability, resolution and label uncertainty. Compare it with a prevalence baseline and inspect calibration across useful slices. Validate probabilities before calculating: clipping an invalid model output would hide a broken probability contract and make a metric look better than the actual system behavior.

labels=[1,0]
probabilities=[.8,.2]
print(sum((p-y)**2 for y,p in zip(labels,probabilities))/2)
Your task

Implement brier(labels,probabilities), validating equal nonempty sequences, binary integer labels and finite probabilities in [0,1]. Return mean squared probability error.