English:Supervised, unsupervised and reinforcement learning - AI Year 7
Introduction

Compare learning from target labels, grouping data without target classes and learning action values from rewards. Classify eight fictional tasks, trace three complete original methods and challenge a result at its boundary.
Distinguish learning signals across eight original tasks
Ask what information drives the update
An algorithm can follow instructions without learning from examples. A learning method changes a retained representation or decision rule using data or feedback. To compare learning approaches, ask what the input is, what is supplied during learning, what output is wanted and how the result will be checked. Do not classify a method from a product name, the presence of a robot picture or a high score alone.
CodeAI: AI, What is Machine Learning? Use the verified introduction to connect examples and a learned representation. The three original methods in this course are deliberately small enough to inspect. They do not train a language model, operate a real robot or analyse anyone's messages or photographs.
Compare three learning signals
Supervised learning uses examples paired with target labels or numeric outcomes. Classification predicts a class; regression predicts a numeric quantity. Unsupervised learning uses data without supplied target labels for the task, for example to explore groupings. Reinforcement learning uses feedback from actions and their rewards in an environment. Real systems can combine approaches; these are useful distinctions rather than a claim that every product belongs to exactly one box.
Human choices remain in all three approaches. Someone selects features, a procedure, a goal and evaluation conditions. Unsupervised does not mean no data, no objective or no responsibility. Reinforcement feedback is a reward signal, not necessarily a correct class label for each example; the reward design can encourage behaviour that misses the actual human purpose.
Classify eight fictional tasks and name the evidence
Attempt the eight cards before uncovering the method and signal columns. The goal is at least seven correct classifications out of eight, with a reason tied to the supplied learning signal. These are explicitly described fictional learning tasks, not claims about how any real commercial system is built.
| Card | Original task | Method: answer | Learning signal: answer |
|---|---|---|---|
| C1 | Learn from fictional messages paired with spam or not-spam labels | Supervised | Known category labels |
| C2 | Learn from invented parcel features paired with measured delivery minutes | Supervised | Known numeric outcomes |
| C3 | Learn from synthetic leaf measurements paired with teacher-prepared species labels | Supervised | Known category labels |
| C4 | Group original story cards by numeric features without supplied genre targets | Unsupervised | Feature values and a grouping procedure |
| C5 | Group invented shape measurements without supplied class targets | Unsupervised | Feature values and a similarity rule |
| C6 | Learn a virtual two-action preference from logged rewards | Reinforcement | Action and reward observations |
| C7 | Improve a fictional maze agent using rewards after moves | Reinforcement | Actions environment transitions and rewards |
| C8 | Learn from invented software reports paired with bug or not-bug labels | Supervised | Known category labels |
For C2, a numerical target makes this supervised regression rather than clustering simply because the data contains numbers. C4 still has numeric data and a chosen grouping procedure; it lacks supplied genre targets for learning. C6 uses observed action rewards, not a list of correct names. Record your own result. The answer table is not a claim that a learner has already reached the target.
Keep training and evaluation distinct
Retaining examples, deriving groups and updating action values all need evidence appropriate to their purpose. Fitting and then checking the same examples is not enough to establish performance on new conditions. A class-prediction match, a useful grouping and a later action reward are different quantities. Do not average them into one impressive-looking universal AI accuracy score.
Trace labelled grouping and reward-based methods in complete code
Supervised example: retain labelled lengths and predict nearby cases
Our original labelled examples associate lengths 1 and 2 with brief, and 8 and 9 with extended. The lengths are fictional numeric units, not real writing assessments. The tiny nearest-neighbour model retains these labelled examples. For a new length, find the smallest absolute distance to a training value and use its label. If equally close examples have different labels, return ASK instead of hiding the ambiguity.
| Training record | Length | Supplied label |
|---|---|---|
| T1 | 1 | brief |
| T2 | 2 | brief |
| T3 | 8 | extended |
| T4 | 9 | extended |
| Separate test record | Length | Prepared expected label |
|---|---|---|
| E1 | 3 | brief |
| E2 | 7 | extended |
Length 3 is closest to labelled 2, so the model outputs brief. Length 7 is closest to labelled 8, so it outputs extended. Both match the two prepared test labels. At length 5, labelled 2 and 8 are equally close and disagree, so the output is ASK. The method does not understand a story, and two matches do not prove reliable classification of real writing. Compare it with a fixed brief baseline, which matches only the first of the two stated expectations.
Unsupervised example: derive a gap without target labels
Use the unlabelled values 1, 2, 3, 8, 9, 10. Our selected classroom procedure sorts them and finds gaps between neighbours: 1, 1, 5, 1, 1. The largest gap is uniquely between 3 and 8. Split there, giving groups 1, 2, 3 and 8, 9, 10, with midpoint 5.5. No brief or extended labels are supplied to this fit.
This one-dimensional largest-gap procedure is original teaching code, not k-means or spectral clustering. You still supplied data, selected a numeric representation and chose the rule that looks for a two-way separation. A user may later interpret the groups, but the program has not discovered that they are genres, abilities or natural kinds. With 1, 2, 3 the largest gap is tied, so the method reports ambiguity. With identical values there is no positive separating gap.
Reward example: update action values from a logged exploration history
Our single-state, two-action example uses six original observations. During the recorded exploration, action A returned rewards 1, 1, 1, while B returned 0, 2, 4. After each observation the program updates the action's observed average reward. A's final average is 1 and B's is 2. The later choice rule selects the higher observed average, so it selects B.
| Observed action | Observed reward | Times this action seen so far | Updated average |
|---|---|---|---|
| A | 1 | 1 | 1.0 |
| B | 0 | 1 | 0.0 |
| A | 1 | 2 | 1.0 |
| B | 2 | 2 | 1.0 |
| A | 1 | 3 | 1.0 |
| B | 4 | 3 | 2.0 |
This is a bounded bandit-style replay that illustrates learning an action value from reward feedback. The exploration schedule and reward history are supplied; the program is not an autonomous online explorer, a complete maze learner or a robot controller. Both actions have been observed. If an action is untried or the two averages tie, our classroom choice rule returns ASK. It does not assume an untried action is worthless.
The predeclared later observation gives B reward zero and fixed action A reward one. Selecting the better training average therefore does not guarantee a better individual future outcome. The later outcome is reported separately and does not alter the fitted training values. This one later result also does not prove that A would always be better.
Inspect the complete original standard-library program
Trace the values on paper, or use an approved Python environment. The code retains labelled examples, derives unlabelled groups and updates action averages. It uses only fictional data. It has no external model, account, camera, microphone or hardware connection.
"""Three original bounded demonstrations; no external model or real agent."""
from copy import deepcopy
import json
def finite_number(value):
return type(value) in [int, float] and float("inf") > abs(value)
def fit_labelled(rows):
if type(rows) is not list or not rows:
raise ValueError("Use labelled training records")
seen = set()
for row in rows:
if type(row) is not list or len(row) != 3:
raise ValueError("Use identifier, length and label")
rid, value, label = row
if type(rid) is not str or not rid or rid in seen:
raise ValueError("Training identifiers must be unique")
if not finite_number(value) or not value > 0:
raise ValueError("Use a positive finite length")
if type(label) is not str or label not in ["brief", "extended"]:
raise ValueError("Use a declared class label")
seen.add(rid)
return deepcopy(rows)
def nearest_label(model, value):
if not finite_number(value) or not value > 0:
return "ASK"
distance = min(abs(value - row[1]) for row in model)
labels = set(row[2] for row in model if abs(value - row[1]) == distance)
return next(iter(labels)) if len(labels) == 1 else "ASK"
def fit_gap_groups(values):
if type(values) is not list or len(values) < 2:
raise ValueError("Use at least two numeric observations")
if any(not finite_number(x) for x in values):
raise ValueError("Values must be finite numbers")
ordered = sorted(values)
gaps = [b - a for a, b in zip(ordered, ordered[1:])]
largest = max(gaps)
if largest == 0:
return dict(status="no-separated-gap", groups=[ordered])
indices = [i for i, gap in enumerate(gaps) if gap == largest]
if len(indices) != 1:
return dict(status="ambiguous-gap", groups=[])
i = indices[0]
return dict(status="split", groups=[ordered[:i + 1], ordered[i + 1:]],
midpoint=(ordered[i] + ordered[i + 1]) / 2)
def fit_action_values(history):
if type(history) is not list or not history:
raise ValueError("Use a nonempty logged action and reward history")
totals = dict(A=0, B=0)
counts = dict(A=0, B=0)
trace = []
for item in history:
if type(item) is not list or len(item) != 2:
raise ValueError("Each observation needs action and reward")
action, reward = item
if type(action) is not str or action not in totals or not finite_number(reward):
raise ValueError("Use a known action and finite reward")
totals[action] += reward
counts[action] += 1
trace.append([action, reward, counts[action], totals[action] / counts[action]])
means = dict((a, totals[a] / counts[a] if counts[a] else None) for a in totals)
return dict(means=means, counts=counts, trace=trace)
def choose_action(state):
if any(state["counts"][a] == 0 for a in ["A", "B"]):
return "ASK"
a, b = state["means"]["A"], state["means"]["B"]
if a == b:
return "ASK"
return "A" if a > b else "B"
def demonstrate():
labelled = [["T1", 1, "brief"], ["T2", 2, "brief"],
["T3", 8, "extended"], ["T4", 9, "extended"]]
model = fit_labelled(labelled)
tests = [["E1", 3, "brief"], ["E2", 7, "extended"]]
predictions = [nearest_label(model, row[1]) for row in tests]
groups = fit_gap_groups([1, 2, 3, 8, 9, 10])
history = [["A", 1], ["B", 0], ["A", 1], ["B", 2], ["A", 1], ["B", 4]]
state = fit_action_values(history)
action = choose_action(state)
later_rewards = dict(A=1, B=0)
return dict(labelled=labelled, tests=tests, supervised_predictions=predictions,
tied_supervised=nearest_label(model, 5), unsupervised=groups,
action_history=history, action_state=state, chosen_action=action,
later_chosen_reward=later_rewards[action], fixed_A_later_reward=later_rewards["A"],
later_outcome_used_for_fitting=False)
if __name__ == "__main__":
print(json.dumps(demonstrate(), indent=2))The complete program was actually executed. Its supervised outputs are brief and extended, its tied query returns ASK, its two numeric groups and midpoint match the calculation, and its learned action preference is B with later reward zero. Keep your own expected and actual results distinct if you change an input. This is limited algorithm execution, not observed learner mastery or a deployed AI system.
Choose suitable evaluation boundaries and a new task
Choose evaluation that fits the method
For supervised classification, compare held-out predictions with justified labels and inspect which errors matter. The introductory confusion matrix places predicted classes against actual classes; it is a general illustration, not the results of our examples. Follow its axis labels rather than assume every matrix uses the same orientation. Our brief/extended example supplies two matches and an additional ambiguous query, not a measured real-world accuracy claim.
For our unlabelled grouping, ask whether the chosen feature and separation help the actual purpose. There is no supplied genre answer key in that fit. A neat numerical split can be unhelpful if the feature omits what a user needs. For the reward example, compare behaviour and later outcomes with the intended purpose, not only the recorded average. A narrow reward can promote an unwanted shortcut.
CodeAI: AI, Training Data & Bias. Use the verified creator discussion to ask what examples cover and omit. Our invented tasks and action observations do not measure bias against real people. Do not convert synthetic label names or clusters into judgements about a learner's worth, ability or identity.
Use contrasting and boundary cases
For the nearest-neighbour model, compare lengths just below five, exactly five and just above five. At five, equally close disagreeing examples produce ASK. If a boundary result surprises you, inspect distances and labels before changing the rule. A copied training query is not the same evidence as an appropriately new evaluation case.
For grouping, permute the same values and check whether the derived groups remain the same. Then test equal largest gaps and identical values. Ambiguity is a result to interpret, not a fault to hide by inventing a natural category. Changing units or features can require reconsidering what distance means; grouping does not become valid simply because an algorithm returns a coloured plot.
For action learning, remove all observations of B and check the ASK fallback, give equal averages and check a tie, then alter the reward definition while preserving the old version. Reward values and later outcomes are different evidence. A reward definition that makes one action look attractive in a tiny history still needs justification and new evaluation for the actual purpose.
Compare two approaches for one fictional archive
An archive wants to organise original cards. If a teacher supplies trusted subject labels for example cards and asks for the same labels on new cards, a supervised formulation is plausible. If the archive instead wants to explore similarity patterns without target classes, an unsupervised formulation is plausible. These answer different questions and need different data and evaluation; unsupervised groups are not automatically substitutes for the teacher's labels.
If a fictional interactive guide chooses actions and receives a declared reward, a reinforcement formulation may be relevant. Reconsider whether that reward serves a worthwhile purpose. A fixed table of correct answers can be simpler for a fixed task; the presence of a score does not automatically mean the software learns from it. No real reader or visitor data is collected for this comparison.
Produce evidence without overstating the result
Keep the eight-card classification with your actual score, the supervised training/test distinction and tie, the unlabelled values and selected procedure, and the action/reward update trace with its weaker later result. Explain one boundary, one alternative method and what remains untested. Revisit labels, features, rewards and permissioned data when transferring to a new original task; do not reuse a toy threshold or average as a general recommendation.
Interactive Tasks
Quiz: Test Your Knowledge
What most directly distinguishes the three approaches in the course? (The learning signal and intended task) (!The colour of the website) (!Whether a robot appears in a picture) (!A single shared accuracy percentage)
What makes the invented delivery-minutes task supervised? (Examples include known numeric outcomes) (!It uses numbers rather than words) (!No result is supplied during learning) (!A reward is earned after an agent action)
Why is the no-data claim about unsupervised learning wrong? (It still uses data and a selected procedure without target labels) (!It always receives a correct target for every case) (!It only works with a robot controller) (!It ignores all feature values)
What label does the supplied nearest-neighbour model give length three? (brief) (!extended) (!ASK because three is always invalid) (!A numeric reward of two)
What does the length-five query produce? (ASK because equally close labels disagree) (!brief with certain universal correctness) (!extended because labels are absent) (!A new training record automatically)
Where is the unique largest gap in the six unlabelled values? (Between three and eight) (!Between one and two) (!Between eight and nine) (!There is no numeric data)
What meaning does the grouping program establish for its two groups? (Only the stated numeric separation under its selected rule) (!Two natural genres known without further evidence) (!Two levels of learner worth) (!A guaranteed correct supervised label)
Why does the reward example select B after the recorded history? (B has observed average reward two compared with one for A) (!B has a supplied correct class label) (!A was never tried) (!The later reward zero was used as training feedback)
What does the later B reward zero demonstrate? (A higher training average does not guarantee each future outcome) (!B can never produce any useful reward) (!A is guaranteed best forever) (!The history was a real robot experiment)
Which comparison is defensible for an archive? (Choose between trusted-label prediction and unlabelled exploration based on purpose) (!Treat all clusters as verified human labels) (!Use a score alone to prove a learning method exists) (!Assume one toy experiment validates every archive)
Memory Game
| Supervised | Learning from examples paired with target outcomes |
| Unsupervised | Finding structure without supplied target labels for the task |
| Reinforcement | Learning action preferences from reward feedback |
| Classification | Predicting a category |
| Regression | Predicting a numeric quantity |
| Policy | A rule for choosing an action |
Drag and Drop
| Predict trusted classes using example class labels | Supervised classification |
| Predict a number from examples with numeric targets | Supervised regression |
| Explore groups without supplied target classes | Unsupervised clustering |
| Update a preference using action rewards | Reward-based learning |
| Return ASK when equally near labels disagree | Ambiguity fallback |
Crossword Puzzle
| LABEL | What target category can a supervised example supply? |
| CLUSTER | What group can an unsupervised method form? |
| REWARD | What feedback can follow an action? |
| POLICY | What rule selects an action? |
| FEATURE | What selected input describes an example? |
| EVALUATE | What do you do when examining evidence against purpose? |
LearningApps
Optional extra practice. Choose an appropriate activity with your teacher. If the external collection is unavailable, use the native activities and independent tasks in this course.
Cloze Text
Open Tasks
Easy
- Classify the eight cards: Cover the method columns, identify each learning signal, then check your own score against seven of eight.
- Trace labelled neighbours: Calculate distances for new lengths three and seven and state the two outputs without claiming general reliability.
- Find the numeric groups: Sort the six unlabelled values, calculate the neighbour gaps and reconstruct the stated two-way split.
- Read the reward trace: Calculate final observed averages for A and B and explain the later action choice.
Standard
- Test the supervised tie: Compare values just below five, exactly five and just above five; explain the nearest-label evidence and ASK route.
- Challenge the no-objective claim: Use the actual unlabelled input and selected largest-gap procedure to explain the human choices remaining in unsupervised learning.
- Compare reward and later outcome: Keep the training action values fixed, report the later B and fixed-A rewards and state what one observation does not establish.
- Compare two archive formulations: Specify data needs, outputs and evaluation for trusted-label prediction versus unlabelled similarity exploration.
Advanced
- Improve an evidence plan: Design new synthetic cases that challenge each demonstrated method, state expectations first and report an actual run or labelled trace with its limits.
- Investigate a reward change: Create an original fictional reward alternative, preserve the old history, recompute a small action preference and examine an unintended incentive.
- Evaluate a grouping feature: Propose a different archive feature, explain how it changes similarity and which evidence would show the groups help the intended user.
- Transfer without overclaiming: Choose an original task and justify a learning signal or a simpler fixed rule, appropriate data permissions, evaluation and a human fallback.
Learning Check
- Classify by the supplied signal: How should the eight original cards be grouped?
- Explain the supervised result and boundary: Why do lengths three, seven and five produce different outcomes?
- Explain unlabelled learning: What remains specified even without target labels?
- Calculate action values and evaluate honestly: Why is B chosen and why is its later result insufficient to prove success?
- Choose method-specific evidence: Why cannot one score cover all three demonstrations?
- Transfer to an archive: What must change when choosing between labelling, grouping and action learning?
Worked checks and assessment guidance
- C1, C2, C3 and C8 use supplied labels or numeric outcomes and are supervised. C4 and C5 group feature data without target labels and are unsupervised. C6 and C7 use action/reward feedback and are reinforcement formulations. These explicit task descriptions justify the classification; they do not reveal the architecture of unspecified real products. Record the learner score only after an actual attempt.
- Three is closest to labelled two, so it gives brief. Seven is closest to labelled eight, so it gives extended. Five is equally close to two and eight with disagreeing labels, so it returns ASK. The two held-out expectations match, while a fixed brief baseline matches one. The fixture does not show understanding of stories or universal classification accuracy.
- The values, feature representation and selected gap procedure remain. Sorted gaps are 1, 1, 5, 1, 1, so the unique largest separation is between three and eight, giving midpoint 5.5 and groups 1, 2, 3 and 8, 9, 10. The procedure is not k-means, and numeric groups acquire no automatic genre or ability meaning. Equal largest gaps return ambiguity; identical values have no positive separation.
- A has rewards 1, 1, 1 and mean 1; B has 0, 2, 4 and mean 2, so the stated choice rule selects B after both actions have been observed. Its predeclared later reward is zero versus one for fixed A. This illustrates a limited reward-learning replay and an uncertain future outcome, not an autonomous explorer, a complete maze policy or proof that A is always better.
- A held-out class match compares a prediction with a label, our unlabelled grouping follows a selected numeric criterion without class targets, and the action example concerns rewards and later choices. Their purposes and evidence differ. Preserve disagreements, ties, baseline comparisons and untested conditions rather than average incompatible quantities into an inflated universal AI score.
- Define whether the goal is predicting trusted classes, exploring similarity or selecting actions under a justified reward. Reconsider features, supplied outcomes, observation history, permissions, evaluation and a manual route. Human choices remain without target labels. A fixed table can be appropriate for a fixed task; merely displaying points does not establish learning from feedback or observed practical competence.
Learning evidence
Retain your eight-card classifications and actual checked score, the learning signal and purpose for each, a labelled nearest-neighbour trace with separate test cases and ASK boundary, the original unlabelled gap calculation with limitations, the action-value update trace and weaker later outcome, expected and actual boundary tests or a labelled paper trace, and a justified archive transfer comparing data needs and evaluation. These are limited learning artefacts, not universal AI reliability, real deployment, independent expert certification or complete curriculum coverage.
OER and Wikipedia
DfE Computing, Key Stage 3 provides the broader algorithms context; this Year 7 AI route is editorial enrichment. Google: What is Machine Learning? distinguishes learning signals and supervised numeric/class targets. scikit-learn: Clustering, overview documents grouping unlabelled feature data and differences between procedures. IBM: Unsupervised learning and IBM: Reinforcement learning provide additional primary context. Relevant sections read 15 November 2026. Our largest-gap routine and logged action-value replay are original teaching methods, not implementations of a source's complete system.
ConfusionMatrix.png, Jackverr, CC BY-SA 3.0. Original binary confusion-matrix diagram unchanged; it illustrates supervised evaluation, not results for our three methods. Follow its actual/predicted axis labels.
https://www.youtube.com/watch?v=OeU5m6vRyCk — CodeAI: AI, What is Machine Learning? https://www.youtube.com/watch?v=x2mRoFNm22g — CodeAI: AI, Training Data & Bias. Actual verified creator records and preview bytes retained, recordings embedded unchanged. No copied transcript, endorsement or relicensing implied.
All eight cards, numeric fixtures, labels, histories, code, later rewards and transfer tasks are original fictional classroom material. The complete small Python was actually executed. No language-model training, autonomous online exploration, physical robot, real learner scoring, pupil data, paid API or external data upload is involved. Program output and a learner's practical achievements remain distinct.
Linked learning areas
aiMOOC Projects
Schulfach+


aiMOOCs


aiMOOC Projekte


MOOCwiki · Deutsch
Nach dem Lernen ist vor dem Lernen
Entdecke direkt den nächsten Lernkurs. Weitere Inhalte erscheinen, wenn Du weiter nach unten scrollst.
Zur MOOCwiki-HauptseiteMediathek
Mediathek wird aus dem Wiki geladen ...
Keine passenden Inhalte gefunden. Bitte ändere Suche oder Filter.
NEWSLernweltNOAH fragen