First exams 2027 · HL only 2027 年首次开考 · 仅 HL

A4.3.4 · Machine learning approaches (HL only)

A4.3.4 · 机器学习方法(仅 HL)

Clustering Techniques in Unsupervised Learning

无监督学习中的聚类技术

Nobody tells the algorithm which group a runner's race time belongs to. Clustering only looks at how similar the data points are to each other, and lets natural groups emerge on their own.

没有人告诉算法一名跑者的比赛用时属于哪一组。聚类只看数据点彼此有多相似,让自然的分组自己浮现出来。

This builds on A4.1.1's definition of unsupervised learning: the training data carries no correct-answer labels at all.

这建立在 A4.1.1 对无监督学习的定义之上:训练数据完全不带任何正确答案标签。

HL only 仅 HL Typically 3–4 marks · AO2 通常 3–4 分 · AO2 Command term: describe 命令词:describe(描述)

Explainer

讲解

Grouping without labels

不带标签地分组

Df

Clustering groups data points so that anything sitting in the same cluster is close (usually measured as distance between feature values) to the rest of that cluster, and further away from points in every other cluster. No labelled "correct" grouping is supplied; the algorithm discovers the structure itself.

聚类把数据点分组,使同一簇内的点彼此更相似(通常以特征值之间的距离来衡量),而与其他簇里的点差异更大。没有提供带标签的"正确"分组;算法自己发现这种结构。

A gym app records each member's weekly workout count and average session length. Nobody labelled any member "casual" or "dedicated", but clustering can still find natural groupings in that data, letting the app suggest a plan that fits the group a member actually falls into.

一款健身应用记录每位会员每周的锻炼次数和平均单次时长。没有人给任何会员贴上"随意型"或"投入型"的标签,但聚类仍然能在这些数据中找到自然的分组,让应用为会员实际所属的那一组推荐合适的计划。

Explainer

讲解

Four clustering families

四种聚类家族

MethodHow it groupsGood fit / weakness
K-meansAssigns each point to the nearest of k centre points (centroids), then moves each centroid to the mean of its assigned points, repeating until stableFast, simple; assumes roughly spherical, similar-sized clusters and needs k chosen in advance
HierarchicalRepeatedly merges the two closest clusters (starting from one point per cluster) into a tree, called a dendrogramShows structure at every scale at once; slower on large data sets
DBSCANGroups points that are densely packed together and marks isolated points as noise/outliersFinds clusters of any shape and does not need k specified; struggles when clusters have very different densities
Mean shiftRepeatedly slides each candidate centre to the mean of nearby points until it settlesWorks on arbitrary shapes without setting k in advance; more computation per point
方法如何分组适合的场景 / 弱点
K-均值把每个点分给最近的 k 个中心点(质心)之一,然后把每个质心移到其所属点的均值位置,重复直到稳定快速、简单;假定簇大致呈球形且大小相近,且需要事先选定 k
层次聚类(从每个点各自成一簇开始)反复合并最接近的两个簇,形成一棵树,称为树状图能一次性展示各种尺度下的结构;在大数据集上较慢
DBSCAN把密集聚集在一起的点分为一组,把孤立的点标记为噪声 / 异常值能找到任意形状的簇,且不需要事先指定 k;在簇的密度差异很大时表现较差
均值漂移反复把每个候选中心滑动到附近点的均值位置,直到它稳定下来无需事先设定 k,就能处理任意形状;每个点的计算量更大

Worked example

例题

K-means, step by step

逐步演示 K-均值

Nine runners plotted by pace (x) and distance run per week (y). Watch k = 2 centroids settle into two natural pace groups.

九名跑者按配速(x)和每周跑量(y)画在图上。看 k = 2 个质心如何落定为两个自然的配速分组。

The basic loop: (1) place k centroids, (2) assign every point to its nearest centroid, (3) move each centroid to the mean of its assigned points, (4) repeat 2 and 3 until no assignment changes.

基本循环:(1)放置 k 个质心,(2)把每个点分给最近的质心,(3)把每个质心移到其所属点的均值位置,(4)重复步骤 2 和 3,直到没有点再改变归属。

Check your understanding

检验你的理解

A data set has a handful of extreme outliers scattered far from any real grouping. Which clustering method handles this best, without those outliers distorting the real clusters?

一个数据集里散布着少量极端的离群点,远离任何真实的分组。哪种聚类方法能最好地处理这种情况,而不让这些离群点扭曲真正的簇?

Common mistake

常见错误

Recurring overgeneralisation about K-means 关于 K-均值反复出现的过度概括

RecurringClaiming K-means "finds the natural clusters in any data set". K-means assumes clusters are roughly spherical and similar in size, because it assigns points purely by distance to a single centre point. Long, thin or unevenly sized clusters, or ones nested inside each other, defeat it. The number of clusters, k, also has to be chosen before running it; K-means cannot decide that number itself.

反复出现声称 K-均值"能在任何数据集中找到自然的簇"。K-均值假定簇大致呈球形且大小相近,因为它纯粹按到单一中心点的距离来分配点。细长的、大小悬殊的,或彼此嵌套的簇都会让它失效。簇的数量 k 也必须在运行前就选定;K-均值本身无法决定这个数字。

✕

Wrong: "K-means clustering works on any data set and automatically works out how many groups there really are."

错误: "K-均值聚类适用于任何数据集,并且会自动算出实际有多少组。"

✓

Right: "K-means requires k to be chosen in advance and assumes clusters are roughly spherical and similar in size, since it assigns points by distance to a centroid. It struggles with irregular shapes or very different cluster sizes; DBSCAN or hierarchical clustering suit those cases better."

正确: "K-均值需要事先选定 k,并假定簇大致呈球形且大小相近,因为它按到质心的距离来分配点。它在处理不规则形状或大小差异很大的簇时表现不佳;这些情况用 DBSCAN 或层次聚类更合适。"

Revision questions

复习题

Specimen-paper style. Write an answer, then reveal the marking points and mark yourself.

采用样卷风格。写下答案,然后展开评分要点给自己打分。

Question 1 · 2 marks 第 1 题 · 2 分

[2]State what makes clustering an unsupervised technique.

[2]说出是什么使聚类成为一种无监督技术。

Question 2 · 4 marks 第 2 题 · 4 分

[4]Describe the four main steps of the K-means algorithm.

[4]描述 K-均值算法的四个主要步骤。

Question 3 · 3 marks 第 3 题 · 3 分

[3]Describe one real-world application of clustering.

[3]描述聚类的一个现实应用。

Question 4 · 3 marks 第 4 题 · 3 分

[3]Explain why DBSCAN does not need the number of clusters set in advance, unlike K-means.

[3]解释为什么 DBSCAN 不像 K-均值那样需要事先设定簇的数量。

Flashcards

记忆卡片

Active recall for this statement’s key terms.

针对本条考纲陈述关键术语的主动回忆练习。

Prototype render · grounded in the IB CS 2027 subject guide and the Hodder and Oxford IB CS 2027 texts for A4.3.4 · not yet wired to live routes