jevexperimentcalibrationspam

Experiment 06 · Calibration

When It Says 80%, Is It Right 80% of the Time? Testing Jev's Calibration on 5,574 Labeled SMS

The central claim about Jev is that its probabilities are honest. That needs real labels, so we used a public dataset of text messages and one yes/no question.

By Daniel Yañez ·

← Blog
Contents · 6 sections

Part of What Is Jev? Six Hands-On Experiments With TypeSafe's System One Model. Every number here comes from a saved run you can download at the end of the post.

Every answer Jev gives comes with a probability, and TypeSafe trains the model specifically so those probabilities mean what they say. That's a claim you can only check with data that has real labels. We used the UCI SMS Spam Collection: 5,574 text messages, 747 of them spam, each labeled by a person years ago for exactly this kind of test.

Setup

state: { sms: "WINNER!! As a valued network customer you have been selected…" }
questions:
  spam: Noul   "Is this SMS spam: an unsolicited commercial, promotional or scam message
               sent in bulk, rather than a personal message between people?"
  kind: Choice ham · spam
→ 5,574 calls · 126 s · 2.13M tokens · $0.09

One sentence of instruction, no examples, no fine-tuning. We ran every message once, eight calls in flight at a time, and kept the probability for each. Then three questions: is it right, is the probability honest, and what threshold would you pick for a real filter.

Is it right?

Accuracy
98.4%
Precision / Recall
92.8% / 95.2%
AUC
0.995
Brier score
0.015

At a 0.5 threshold it caught 711 of 747 spam messages and wrongly flagged 55 of 4,827 personal ones. The Choice version of the same question gave the same AUC with slightly different precision and recall; the two primitives disagreed by 0.04 on average. For context, always predicting the base rate would score a Brier of 0.116; the model scored 0.015.

Histogram of predicted spam probability, personal messages and spam shown separately on a log scale
Where the probabilities landed, by true label. Personal messages pile up at the left, spam at the right; the middle holds a few dozen messages out of 5,574.

Is the probability honest?

Reliability diagram: mean predicted probability per bin against the actual spam rate, with the perfect-calibration diagonal
The reliability diagram. A dot on the dashed line means the stated probability matched reality; a dot below it means the model was more sure than it should have been.

Seventy-one percent of messages got an answer below 0.05 or above 0.95, and those bins sit within three points of the diagonal: when it says "almost certainly spam" or "almost certainly not", it's right at that rate. Expected calibration error over all bins was 0.042.

The middle of the range tells a more specific story. From 0.1 to 0.8 the actual spam rate ran 7 to 28 points *below* the stated probability. When the model is unsure, it's a little more suspicious than the messages deserve. Only 140 messages (2.5%) live in that 0.3–0.7 zone, so the effect on the overall numbers is small, but a threshold placed there should account for it, and the bins are thin (25 to 55 messages each), so their gaps are themselves uncertain.

P(spam) binMessagesMean PActual spam rateGap
0.0–0.14,2480.0310.001−0.030
0.1–0.23660.1310.014−0.118
0.2–0.31130.2360.044−0.192
0.4–0.5320.4410.219−0.222
0.6–0.7250.6360.360−0.276
0.8–0.9550.8540.945+0.092
0.9–1.06230.9650.989+0.023

Picking a threshold

Precision and recall as the threshold moves from 0.05 to 0.95
Precision and recall across thresholds. For a spam folder, where misfiling a personal message is the worse mistake, 0.7 to 0.9 is the useful range.
ThresholdPrecisionRecallPersonal messages misfiledSpam missed
0.30.8680.97611118
0.50.9280.9525536
0.70.9690.9172262
0.90.9920.8155138

About the mistakes

Eleven messages labeled spam got a probability under 0.2, and several of them are forwarded jokes that the dataset's labelers filed as spam ("How come it takes so little time for a child who is afraid of the dark to become a teenager who wants to stay out all night?"). Ten personal messages got over 0.8, and several are plainly promotional ("HCL Chennai requires FRESHERS for voice process, excellent English needed, call Ms. Suman"). The true error rate is somewhat below the measured 1.6%. We mention this because it's the kind of thing a probability lets you see: the confident disagreements are worth a look, and some of them are the label's fault.

What we'd do with this

For a yes/no judgment on short text, the probability is something you can build on: gate automatically at the extremes, route the thin middle to a person, and expect the rates you were promised. If an application needs the middle of the range to be an exact probability rather than "unsure, leaning yes", a simple re-mapping from a table like the one above does it. The whole dataset cost nine cents and two minutes, which makes re-checking calibration on your own labeled data a routine thing rather than a project.

Download the run: 5,574 messages with label, text and P(spam) (CSV)In download/sms-spam-calibration.csv, with the scripts to reproduce it and the chart page.

Keep reading

When It Says 80%, Is It Right 80% of the Time? Testing Jev's Calibration on 5,574 Labeled SMS | Studio Pro