Prediction: your first ML idea
Lab goal: build a mini guess game
Before you write clever code, name what your toy game is trying to prove — and what five practice rounds cannot prove.
1Try it yourself
Playground
Prediction: your first ML idea
Tune a tiny rule-based “model.” Watch accuracy change.
Mom: dinner at 7
Pred: not spam · Truth: not spam · ✓
URGENT!!! click now to WIN money
Pred: spam · Truth: spam · ✓
School homework reminder
Pred: spam · Truth: not spam · ✗
FREE FREE FREE act immediately!!!
Pred: spam · Truth: spam · ✓
2Learn the idea
Read
What success means in this lab
Success is not “I copied a tutorial.” Success is evidence you can show a friend:
- You chose a threshold (we start at
0.5). - You turned five scores into five guesses.
- You counted four kinds of outcomes — true hits, false alarms, true clears, and misses — and computed accuracy on this tiny set.
That tiny set is your practice court. Five labeled rounds are enough to check your math. They are not enough to claim the game works for every classmate’s inbox or every gym shot in the world.
Read
The shared practice fixture
Run this exact path. Later pages reuse the same lists so everyone can compare notes.
truth = [1, 0, 1, 1, 0]
scores = [0.8, 0.3, 0.6, 0.9, 0.2]
threshold = 0.5
preds = [int(score >= threshold) for score in scores]
pairs = list(zip(truth, preds))
tp = pairs.count((1, 1)); fp = pairs.count((0, 1))
tn = pairs.count((0, 0)); fn = pairs.count((1, 0))
accuracy = (tp + tn) / len(pairs)
print(preds, f"accuracy={accuracy:.2f}", tp, fp, tn, fn)
Expected evidence:
[1, 0, 1, 1, 0] accuracy=1.00 3 0 2 0
Read
Kid map of the lines
truth— the real answers for five rounds (1 = yes, 0 = no).scores— the model’s confidence each round.threshold— the “is it high enough?” cutoff.preds— yes/no guesses from score ≥ threshold.tp,fp,tn,fn— four scoreboard buckets (correct yes, wrong yes, correct no, wrong no).accuracy— fraction of rounds where guess matched truth.
On this fixture the guesses match truth perfectly (accuracy=1.00). Celebrate the math — then write in your notebook: perfect on five practice rounds ≠ ready for every phone.
Read
Claim before you build more
Fill this sentence: “Given five labeled scores and a threshold, my mini prediction game will print guesses plus TP/FP/TN/FN that match hand counting.” Tape the expected line beside it. If someone later swaps that for “it felt smart,” the sticky note is how you push back.
Go deeper
Before you start
Why this matters
Imagine a lunchtime mini game on a Chromebook: spam message? or will this free throw go in? For each round you get a score from 0 to 1 (how “spammy” or how “make-able” it looks) and a cutoff called a threshold. If the score is at least the threshold, the game guesses yes (1). Otherwise it guesses no (0).
On sticky paper, write: (1) the decision a player uses the output for, and (2) one fake win — something that looks successful but does not prove the claim. Example fake win: “It printed numbers, so it works on every phone.”
Related lessons
Check your understanding
Page assessment
Answer from memory. Completion is saved from this evidence, not from opening the next page.
All responses are required.