Prediction: your first ML idea
Set the rules of the guess lists
A fair mini game needs clear rules for what may enter the scoreboard — before anyone argues about who “won.”
1Learn the idea
Read
The contract for this game
Think of the code as a board game with three piles:
- Truth pile — only
0or1for each round (did the shot go in? was it spam?). - Score pile — numbers between
0and1(how strong the clue looked). - Threshold — one cutoff, also between
0and1.
Same length for truth and scores. No secret third list. No pasting real classmate messages into the demo — use made-up practice rounds.
If a score is out of range or the piles do not line up, that is a rules bug, not proof that “the AI is dumb.” Fix the rules before you trust the scoreboard.
Read
Same working path, rules angle
We still run the happy fixture so you can see a clean contract in action:
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
Why this setup counts as a contract
- Every
scoresits in[0, 1], and so doesthreshold. truthandscoresboth have length 5, sozippairs them honestly.- Guesses are only
0or1, never a mystery third label. - The printout names predictions and the four buckets, so nobody can hide behind a lonely accuracy number.
Write a one-line rule for each field: required shape, allowed range, and what is forbidden (real phone numbers, real chat logs, scores above 1).
Read
Separate “check the lists” from “count the scoreboard”
First make sure the piles are legal. Only then count TP/FP/TN/FN. Mixing those jobs makes debugging feel like random blame: Was the threshold wrong, or did someone paste six scores and five truths?
Go deeper
Before you start
Why this matters
You are writing the rule card taped to the classroom Chromebook: what lists are allowed, what a score must look like, and what the threshold means. Invent one broken input a classmate might type by accident (a score of 1.7, a threshold of -2, or a truth list longer than the scores list). Predict what should happen: a clear “nope,” not a silent wrong answer.
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.