← IGCSE Computer Science Paper 1

Machine learning adapting its own data

A machine learning program changes its own stored data by adding, updating or removing items as it meets new cases, e.g. spam marked by users, and uses that data in later decisions.

Understanding Machine learning adapting its own data in IGCSE Computer Science Paper 1

What it does: Removing an item from the stored list shows the program changing its own data by deleting information that is no longer correct. In machine learning the program itself changes its data. It does not wait for a programmer to edit it. The changed data is used in later decisions, so the filter improves over time.

Common mistakes: When a user marks an email as spam, the program should add the new word to its stored data. remove() takes data away, so it should be spam_words.append(new_word). The keyword is misspelt. It should be return, so the function gives back the updated spam count.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 662–678) and word search (Modules 652–678).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A spam filter is told by a user that an email is spam. What does a machine learning spam filter do with this information?
It adds the email's features to its stored dataIt ignores the email and keeps its data unchanged
Matches
IF user_marks_spam THEN fixed_rules.append(email) ENDIF
↓
A fixed rule list is not being changed by the program itself. Machine learning should add the marked email to its own stored examples (the data), not leave it in rules that only a programmer edits.
Applying
Meanings
Term
self-updating data
Meaning
A machine learning program changes its own stored data by adding, updating or removing items as it meets new cases, e.g. spam marked by users, and uses that data in later decisions.
Practice
INPUT word
Testing
Gaps
spamData.(emailWords)
Check Answer
Spots
3if user_marked_spam:
4 spam_words.remove(new_word)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Wolverine' badge — Fearless Coder, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A spam filter is told by a user that an email is spam. What does a machine learning spam filter do with this information?
A. It ignores the email and keeps its data unchanged
B. It adds the email's features to its stored data ✓
A machine learning program changes its own stored data by adding new examples as it meets new cases.
2. Which statement describes machine learning adapting its own data?
A. The program updates its stored values using new cases ✓
B. A programmer must rewrite the stored values by hand each time
In machine learning the program itself changes its data. It does not wait for a programmer to edit it.
3. A spam filter has stored that the word 'prize' appears in 60% of spam emails. After more users mark emails, it changes the value to 75%. What is this?
A. Updating a stored value ✓
B. Deleting the filter's rules
Changing an existing stored value as new cases arrive is updating the data.
4. Which is an example of a machine learning program removing stored information?
A. The user deleting their own inbox folder
B. Deleting an old example that no longer matches current spam ✓
The program can remove items from its own data when they stop being useful for its decisions.
5. Why does a spam filter keep the data it has added or updated?
A. It uses the data in later decisions about new emails ✓
B. It only stores the data and never uses it again
The changed data is used in later decisions, so the filter improves over time.

Match the Pairs

spam_examples.append(new_email) → The program adds a newly marked email to its stored data so it can learn from it
word_score["free"] = word_score["free"] + 1 → The program updates a stored value after seeing another spam email containing that word
A spam filter removes an old example from its data when the user says it was marked wrongly → spam_examples.remove(old_email)
The updated stored data is used on later decisions, so the next email is judged using what was learned → IF word_score["free"] > 5 THEN mark_as_spam
IF user_marks_spam THEN fixed_rules.append(email) ENDIF → A fixed rule list is not being changed by the program itself. Machine learning should add the marked email to its own stored examples (the data), not leave it in rules that only a programmer edits.
new_email = get_email() IF word_score["free"] > 5 THEN mark_as_spam (word_score is never changed) → The program decides but never updates its stored data after the user marks the email. It must update word_score so the new case is used in later decisions.

Key Term

self-updating data
A machine learning program changes its own stored data by adding, updating or removing items as it meets new cases, e.g. spam marked by users, and uses that data in later decisions.

Fill in the Blanks

1. IF userMarksSpam = TRUE THEN spamData.add(emailWords) ENDIF
Hint: Type the method name that puts a new example into the stored data.
2. IF word IN spamEmail THEN spamScore ← spamScore + 1 ENDIF
Hint: Type the arithmetic operator that raises the stored value when the program sees another example.
3. IF userSaysNotSpam THEN spamData.remove(oldEmail) ENDIF
Hint: Type the method name that deletes an item from the stored data.
4. score ← spamData.count(newEmail) IF score > 5 THEN OUTPUT "Move to spam"
Hint: Type the variable that holds the value worked out from the stored data, so it is used in the decision.
5. spamData.add(email) result ← spamData.count(nextEmail)
Hint: Type the name of the stored data that now includes the new example and is used in the next decision.

Spot the Error

Question 1
A spam_words = ["win", "free"]
B new_word = "prize"
C if user_marked_spam:
D spam_words.remove(new_word)
Line D — When a user marks an email as spam, the program should add the new word to its stored data. remove() takes data away, so it should be spam_words.append(new_word).
Question 2
A def mark_spam(count):
B retrun count + 1
C spam_count = mark_spam(5)
D print(spam_count)
Line B — The keyword is misspelt. It should be return, so the function gives back the updated spam count.
Question 3
A scores = {"free": 2, "win": 3}
B word = "free"
C scores[word] == scores[word] + 1
D print(scores)
Line C — == compares two values and does not store anything, so the stored score is never updated. It should use the assignment operator =.
Question 4
A trusted = []
B trusted.add("Sam")
C if "Sam" in trusted:
D print("Inbox")
Line B — Python lists have no add() method. To store a new item in the list, use trusted.append("Sam").
Question 5
A spam_words = ["free", "win"]
B spam_words.remove(win)
C print(len(spam_words))
Line B — win is not in quotes, so Python treats it as an undefined variable. The word to remove must be a string: remove("win").

Student with a class code? Join your class →