Open project
Build a Python app where a trained model recognises something, and rules you write decide what to do about it.
Each part does the job it is best at. The model handles the messy, real-world input, such as a photo, a pose or a sound. The rules handle the parts you can describe exactly: counting, scoring, looking things up, and deciding what to do when the model is not sure.
Before you start: you have built one rules-based app (project A) and one trained app (project B).
The parts fit together like this:
input → trained model → label + how sure → your rules → response
Your rules should use how sure the model is, not only its label. What does your app do when it is not sure?
Before you start, write one sentence: who is it for, and what will it tell or do for them?
What to hand in
.py file, your model file and any data files.Check your app before you hand it in
Good habits. Only record yourself, or people who have said yes. Check what is behind you before you record. Your pictures and sounds stay on your computer.
These show a finished project at about the level to aim for. Yours will be different, and that is fine.


These light up when code you paste uses them. The starters already use some of them, so check the parts you wrote use them too. Click one to see where you learned it.
This project runs on your own computer, not in this page.
Tick each one when it is true of your project. Nobody marks it: be honest with yourself.
# Pipeline:
# photo -> MODEL (Rock/Paper/Scissors + how sure) -> RULES (cut-off, who wins, score) -> result
# MODEL: telling a hand shape apart in a photo is too messy for rules.
# RULES: who beats whom, keeping score and when the game ends are exact.assert run([("Rock", 0.95, "Scissors")]) == ({"you": 1, "computer": 0}, "You win the round")
assert run([("Rock", 0.95, "Paper")]) == ({"you": 0, "computer": 1}, "I win the round")
assert run([("Rock", 0.95, "Rock")]) == (NEW_GAME, "Draw")
assert run([("Paper", 0.65, "Rock")]) == (NEW_GAME, "Show it again") # unsure: not playedlabel, confidence = model.top(image) # the MODEL part
computer = random.choice(list(BEATS))
score, headline, detail = play(score, label, confidence, computer, int(target)) # the RULES partif label is None or confidence < CUTOFF:
return score, "Show it again", f"I'm not sure that was {label} ({confidence:.0%}), so that throw doesn't count."Tick every milestone first.
You built it with: