# Pattern recognition

> CIE A-Level Computer Science · 9618 (2022-2024)
> Source: https://www.owlsprep.com/study/cie-9618-u13-pattern-recognition/

This module covers core pattern recognition concepts for CIE A-Level 9618, including key types, common algorithms, and AI applications. You will learn to solve standard exam-style problems on classification and clustering.

**Prerequisites:** [Basic computational thinking concepts](https://www.owlsprep.com/study/cie-9618-u13-intro-to-computational-thinking/); [Fundamentals of artificial intelligence](https://www.owlsprep.com/study/cie-9618-u13-intro-to-ai/)

## Learning objectives

- Distinguish between supervised and unsupervised pattern recognition problems
- Apply k-NN and k-Means algorithms to simple exam-style problems
- Identify appropriate use cases for pattern recognition in AI
- Answer common exam questions on core pattern recognition concepts

## Core Concepts of Pattern Recognition

**Pattern Recognition** — The process of using computer systems to automatically identify regularities, patterns, or features in raw input data, for classification or grouping of inputs

*Example:* Identifying handwritten digits from scanned document images

All pattern recognition workflows follow a standard structure. The first and most critical step is **feature extraction**: selecting only the relevant attributes from raw input data to reduce complexity and improve accuracy. Irrelevant data (e.g. cup color when sorting cups by size) is discarded.

- Common input types: images, text, audio, sensor measurements, transaction data
- Output types: labelled classes (supervised) or natural groups (unsupervised)

**Worked example:** A factory wants to automate sorting of bottles by volume (250ml, 500ml, 1L) using a laser sensor. Outline the steps of a pattern recognition system for this task.

1. 1. Extract the relevant feature from raw sensor data: the measured height of the bottle, which correlates directly with volume. Discard irrelevant data like bottle color or label text.
2. 2. Compare the extracted height against pre-defined thresholds for each volume class.
3. 3. Assign the bottle to the matching pre-defined volume class as the final output.

> **Exam tip:** Always mention feature extraction as the first step in any pattern recognition workflow question to earn full marks.

## Types of Pattern Recognition: Supervised vs Unsupervised

**Classification** — Supervised pattern recognition where inputs are assigned to one of a set of pre-defined, labelled classes. The system is trained on already labelled training data.

*Example:* Sorting incoming emails into 'spam' and 'not spam' classes

**Clustering** — Unsupervised pattern recognition where natural groups (clusters) of similar inputs are identified, with no pre-defined class labels or training data.

*Example:* Grouping customer purchase data to identify hidden market segments

**Comparing methods**

Key differences between classification and clustering:

- **Classification** — Supervised learning, uses labelled training data, pre-defined output classes
  - Pros: Predictable output, easy to measure accuracy
  - Cons: Requires large labelled dataset, cannot find new groups

- **Clustering** — Unsupervised learning, no labelled training data, output groups are discovered
  - Pros: No labelled data required, discovers hidden patterns
  - Cons: Output groups are unlabelled, harder to evaluate accuracy

**Worked example:** A biologist has measurements of 100 new beetle samples, with no prior information on how many species are present. Is this a classification or clustering problem? Explain your answer.

1. 1. Check for pre-defined labelled classes: the biologist has no prior information about existing species, so no labels are provided.
2. 2. The goal is to identify natural groups of similar beetle measurements, not assign to known classes.
3. 3. Conclusion: This is an unsupervised clustering problem.

## Common Algorithms for Exams

CIE 9618 expects you to be able to apply two simple common pattern recognition algorithms to small datasets: k-Nearest Neighbours (k-NN) for classification, and k-Means for clustering.

**k-Nearest Neighbours** — A simple classification algorithm that assigns a new unlabelled input to the most common class among its k closest (most similar) labelled training points.

*Notation:* k-NN

*Example:* Classifying a new flower based on the species of its 3 closest neighbours in measurement space

**k-Means** — A clustering algorithm that partitions input data into k pre-specified distinct clusters by minimising the distance between each data point and the cluster's average centroid.

*Notation:* k-Means

*Example:* Partitioning 100 customer data points into 5 distinct spending groups

**Worked example:** Use k-NN with $k=3$ to classify a new data point with feature $(2, 3)$. Existing labelled points: A(1,2) = Red, B(1,4) = Red, C(3,2) = Blue, D(4,3) = Blue.

1. Calculate Euclidean distance between the new point and each existing point:
2. $$d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$$
3. Distance to A: $\approx 1.41$, B: $\approx 1.41$, C: $\approx 1.41$, D: $2$. The 3 closest neighbours are A, B, C.
4. Count classes: 2 Red, 1 Blue. Majority class is Red.
5. Final classification: Red

> **Exam tip:** Always show your distance calculations and majority vote step for k-NN questions to get full marks.

## Common pitfalls

- **Wrong:** Confusing classification and clustering as the same type of pattern recognition.
  - Why it fails: Examiners regularly test the difference between supervised and unsupervised learning, and mixing them up loses marks.
  - Correct: Remember classification uses pre-defined labelled classes (supervised), while clustering finds unlabelled natural groups (unsupervised).
- **Wrong:** Forgetting to mention feature extraction as the first step in a pattern recognition workflow.
  - Why it fails: Many candidates skip this step, but exam mark schemes require it for full marks.
  - Correct: Always explicitly state feature extraction as the initial step of any pattern recognition process.
- **Wrong:** Leaving a tied vote unresolved in k-NN calculations.
  - Why it fails: Candidates often stop when there is an even k and a tie, losing marks.
  - Correct: Break ties by either reducing k by 1 or using weighted distance to prioritise closer neighbours.
- **Wrong:** Assuming k-Means automatically detects the number of clusters.
  - Why it fails: This is a common misconception tested in multiple-choice and written questions.
  - Correct: The number of clusters k must always be specified by the user before running k-Means.

## Cheatsheet

| Concept | Learning Type | Key Feature |
| --- | --- | --- |
| Pattern Recognition | Any | Extract features → identify patterns |
| Classification | Supervised | Assign inputs to pre-defined labelled classes |
| Clustering | Unsupervised | Find natural groups in unlabelled data |
| k-NN | Classification | Majority vote of k closest neighbours |
| k-Means | Clustering | User specifies k, minimise distance to centroid |

## What's next

Pattern recognition is a foundational concept for all advanced AI and machine learning topics in CIE 9618. Mastering the difference between supervised and unsupervised pattern recognition will help you understand more complex algorithms like decision trees and neural networks. Pattern recognition questions regularly appear in Paper 1, so practicing applying k-NN and k-Means to small datasets will help you earn easy marks in the exam. Next you can explore specific types of machine learning in more depth and build on your core knowledge.

- [Object-oriented problem solving](https://www.owlsprep.com/study/cie-9618-u13-object-oriented-problem-solving/)
- [Declarative problem solving](https://www.owlsprep.com/study/cie-9618-u13-declarative-problem-solving/)
- [Artificial intelligence fundamentals](https://www.owlsprep.com/study/cie-9618-u13-artificial-intelligence-fundamentals/)

---

From [OwlsPrep](https://www.owlsprep.com) — free study guides for A-Level, IB, AP and IGCSE, written against the official syllabus. Canonical page: https://www.owlsprep.com/study/cie-9618-u13-pattern-recognition/
