FIT1043 · Introduction to Data Science
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.
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
Classification vs regression, and the k-means steps
- +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.
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.
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.
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.