Monash University · FACULTY OF INFORMATION TECHNOLOGY

FIT1043 · Introduction to Data Science

- one subject, every graph, every model, every mark
Information Technology14 Chapters7-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 7 of 11 · FIT1043

Classification & Clustering

Week 7 of Monash FIT1043 Introduction to Data Science covers the two most examinable modelling families: classification (a categorical target) versus regression (a continuous target), and clustering (unsupervised grouping). It teaches decision trees and random forests conceptually, the k-means algorithm step by step, and how to evaluate a classifier with a confusion matrix (accuracy, sensitivity/recall, specificity, precision). These appear directly on the final — classification vs regression and k-means are both sample-exam short answers — and the metrics feed Assignment 1.

In this chapter

What this chapter covers

  • 01Classification vs regression: categorical/discrete target (spam vs not-spam) vs continuous target (price, salary)
  • 02Decision trees and regression trees: how splits partition the data (concept)
  • 03Random forest: an ensemble of decision trees (concept)
  • 04k-means clustering: unsupervised grouping of similar points into k clusters
  • 05The k-means algorithm: define K, initialise centroids, assign points to nearest centroid, update centroids, repeat until centroids stop changing significantly
  • 06Confusion matrix: TP, FP, FN, TN and accuracy = (TP+TN)/total
  • 07Sensitivity/recall = TP/(TP+FN); specificity = TN/(TN+FP); precision = TP/(TP+FP)
  • 08Choosing the metric: a fraud detector optimises recall; a spam filter optimises precision/specificity
Worked example · free

Classification vs regression, and the k-means steps

Q [2 marks]. (a) You want to predict a person's salary from their age and job title. Is this classification or regression, and why? (b) List the steps of the k-means algorithm. (2 marks)
  • +1(a) REGRESSION, because salary is a CONTINUOUS numeric target. Classification predicts a categorical/discrete label (e.g. spam vs not-spam); regression predicts a continuous value (e.g. price or salary), so a salary prediction is regression.
  • +1(b) k-means: (1) define K (the number of clusters); (2) initialise the K centroids; (3) assign each data point to its nearest centroid; (4) update each centroid to the mean of its assigned points; (5) if the centroids changed significantly from the previous iteration, return to step 3, otherwise stop.
(a) Regression — salary is a continuous target (classification would predict a category like spam/not-spam). (b) k-means: define K; initialise centroids; assign each point to its nearest centroid; update centroids to the mean of their points; repeat from the assign step until the centroids stop changing significantly.
Sia tip — Decide classification vs regression by the TARGET: categorical -> classification, continuous -> regression. For k-means, remember the loop is assign-then-update, repeated until convergence, and that it is unsupervised (no labels). Ask Sia to quiz you on the five k-means steps in order — it explains each one and never just hands over the answer.
Glossary

Key terms

Classification vs regression
Two supervised tasks distinguished by the target type: classification predicts a categorical/discrete label (spam vs not-spam); regression predicts a continuous value (price, salary).
Decision tree
A model that repeatedly splits the data on feature thresholds to reach a prediction at each leaf; a regression tree does the same for a continuous target.
Random forest
An ensemble of many decision trees whose predictions are combined, typically more accurate and robust than a single tree.
k-means clustering
An unsupervised algorithm that groups points into k clusters by iterating assign-to-nearest-centroid and update-centroids until the centroids stabilise.
Confusion matrix
A 2x2 table of true/false positives and negatives, from which accuracy = (TP+TN)/total, recall = TP/(TP+FN), specificity = TN/(TN+FP) and precision = TP/(TP+FP) are computed.
Sensitivity vs specificity
Sensitivity (recall, TPR) = TP/(TP+FN) answers 'when it is actually positive, how often is the prediction right?'; specificity (TNR) = TN/(TN+FP) does the same for negatives.
FAQ

Classification & Clustering FAQ

How do I decide if a problem is classification or regression?

Look at the target variable. If it is categorical or discrete — spam vs not-spam, pass vs fail, which species — it is classification. If it is a continuous number — price, salary, temperature — it is regression. Predicting a salary is regression because salary is continuous; predicting whether an email is spam is classification.

What are the steps of k-means?

Define K (the number of clusters); initialise the K centroids; assign each point to its nearest centroid; update each centroid to the mean of the points assigned to it; then check whether the centroids moved significantly — if they did, repeat from the assign step, otherwise stop. It is an unsupervised method, so there are no target labels.

What is the difference between recall and precision?

Recall (sensitivity) = TP/(TP+FN) measures, of the truly positive cases, how many you caught — it is what a fraud detector wants high, because a missed fraud is costly. Precision = TP/(TP+FP) measures, of the cases you flagged positive, how many really were — closely tied to specificity, it is what a spam filter wants high, because wrongly binning a real email is costly.

Is clustering supervised or unsupervised?

Clustering, including k-means, is unsupervised: there are no target labels, and the algorithm groups points by similarity alone. Classification and regression are supervised because each training example carries a known target. This supervised-vs-unsupervised distinction is a common one-mark MCQ.

Can AI help me with classification and clustering in FIT1043?

Yes. Sia can drill you on classification vs regression, recite and explain the k-means steps, and compute confusion-matrix metrics with you, step by step, then set fresh practice in the exam's style. It explains the methods and checks your reasoning; it does not do Assignment 1 or your exam for you, and Monash academic-integrity rules apply. Confirm details on Moodle.

Study strategy

Exam move

Week 7 is the densest source of exam short answers, so prioritise three recall items: classification vs regression (decide by target type, with an example each), the five k-means steps in order (and that it is unsupervised), and the confusion-matrix formulas (accuracy, recall/sensitivity, specificity, precision) with the application rule (fraud -> recall, spam -> precision/specificity). Practise computing all four metrics from a given 2x2 table until it is fast, because that is exactly what Assignment 1 and the final ask. Keep decision trees and random forests at the conceptual level the unit teaches — how splits work and that a forest is an ensemble of trees.

Working through Classification & Clustering in FIT1043? Sia is AskSia’s AI Information Technology tutor — ask any FIT1043 Classification & Clustering question and get a clear, step-by-step explanation grounded in how FIT1043 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 47 of your Monash University subjects - and 1,000+ Bibles across every Australian university.
Sia - your FIT1043 tutor, unlimited, worked the way the exam marks it
The full 7-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$25/ month
30-day money-back · cancel in one tap · how it works
Unlock the full FIT1043 Bible + 47 Monash University subjects解锁完整 FIT1043 Bible + Monash University 47 门科目
$25/mo