COMP5318 Machine Learning and Data Mining
COMP5318 Overview
- University of Sydney
- S2 2026
- 11 chapters
- Computer Science
COMP5318 Machine Learning and Data Mining is the University of Sydney's postgraduate introduction to the algorithms that learn from data — from k-nearest neighbour, Naïve Bayes and decision trees to support vector machines, neural networks and reinforcement learning.
- Assessed by Weekly Homework Quizzes (×10) 5% · Assignment 1 (group) 15% · Assignment 2 (group) 20% · Final Exam 60%
- Key terms Supervised learning, Unsupervised learning, Overfitting, Euclidean distance
- How to prepare Treat COMP5318 Machine Learning and Data Mining at the University of Sydney as a breadth unit assessed mostly by a 60% closed-book final: keep pace…
- Most asked Where can I find past exam papers or practice for COMP5318?
How COMP5318 is assessed
| Component | Weight | Format |
|---|---|---|
| Weekly Homework Quizzes (×10) | 5% | Canvas quizzes weeks 2-11, direct application of that week's lecture; due Tuesdays |
| Assignment 1 (group) | 15% | A program to solve a given task + short report, ~Week 7 |
| Assignment 2 (group) | 20% | A program + report discussing results, ~Week 11 |
| Final Exam | 60% | Paper-based, 2 hours, closed book (non-programmable calculator only), formal exam period |
What COMP5318 covers
Eleven chapters trace COMP5318 from foundations and distance measures through regression, Naïve Bayes, trees, SVMs and PCA, neural and deep networks, and on to clustering, Markov models and reinforcement learning.
Foundations of Machine Learning & Data Mining
Supervised vs unsupervised, empirical vs true risk, normalisation and distance measuresThis opening chapter of University of Sydney COMP5318 Machine Learning and Data Mining sets up the vocabulary and rules every later week reuses: the supervised vs unsupervised split, the empirical-risk vs true-risk trade-off that explains overfitting, feature normalisation, and the distance and similarity measures that most algorithms compare points with.
- Tell supervised from unsupervised learning, and classification from regression
- Name what clustering and dimensionality reduction do when there are no labels
- Define empirical (training) risk vs true (generalisation) risk with 0/1 loss
- Read the training-vs-test error U-curve to spot underfitting and overfitting
- Apply min-max normalisation x' = (x - min) / (max - min) to rescale a feature
- Contrast min-max scaling with z-score standardisation and know when each helps
k-Nearest Neighbour & Rule-Based Classifiers
Lazy learning, choosing k, Euclidean/Manhattan distance, speed trade-offsThis chapter covers k-Nearest Neighbour (k-NN) and the rule-based classifiers (1R and PRISM) from the Week 2 classification block of COMP5318 Machine Learning and Data Mining at the University of Sydney.
- Why k-NN is a lazy learner: it stores the data and defers all work to prediction time
- The four-step k-NN algorithm: distance, sort, take k nearest, majority vote (average for regression)
- Computing Euclidean (straight-line) and Manhattan (city-block) distances by hand
- Why you must scale features before measuring distance, so no large-range feature dominates
- How k controls the decision boundary: small k overfits, large k oversmooths, k=n predicts the majority
- Choosing k with validation error, and the rule of thumb k ≤ √(number of training examples)
Linear & Logistic Regression, Regularization
Least squares, R², log-odds sigmoid, Ridge (L2) and Lasso (L1)This Week 3 topic of COMP5318 Machine Learning and Data Mining at the University of Sydney builds your first explicit parametric models: linear regression fitted by least squares and scored with R², and logistic regression, which sends the same linear score through a sigmoid to predict a class probability.
- Fit a straight line ŷ = b₀ + b₁x by least squares using the closed-form slope and intercept formulas
- Understand why least squares minimises SSE (squared residuals), not the raw sum of residuals
- Split the spread of y with the identity SST = SSR + SSE and read each sum
- Compute R² = SSR/SST = 1 − SSE/SST and interpret it as the fraction of variation explained
- Recover the correlation r = ±√R², taking the sign from the slope direction
- See how logistic regression turns the linear score into a probability with the sigmoid and the log-odds link
Naïve Bayes & Model Evaluation
Bayes theorem, Gaussian NB, cross-validation, confusion matrix, precision/recall/F1This chapter of University of Sydney COMP5318 Machine Learning and Data Mining pairs a probabilistic classifier with the tools that judge every model.
- State Bayes theorem and name the prior, likelihood, posterior and evidence
- Apply the Naïve Bayes rule: classify to the class with the largest prior times product of likelihoods
- Estimate nominal likelihoods as training-count fractions
- Spot the zero-frequency problem and fix it with Laplace (add-one) smoothing
- Use the Gaussian density with per-class mean and sample standard deviation for a numeric feature
- Choose between holdout, k-fold (stratified) cross-validation and leave-one-out to estimate true error
Decision Trees & Ensembles
Entropy, information gain, pruning, bagging, boosting, random forestThis Week 5 topic of COMP5318 Machine Learning and Data Mining at the University of Sydney builds a classifier you can read as if-then rules: a decision tree that splits, at each node, on the feature with the highest information gain — the largest drop in entropy.
- Compute the entropy H(S) = −Σ pᵢ log₂ pᵢ of a labelled node in bits, using 0·log₂(0) = 0
- Read the entropy scale: 0 at a pure node, a maximum of 1 bit at a two-class 50/50 split
- Calculate the information gain of an attribute as parent entropy minus weighted child entropy
- Apply the split rule: choose the attribute with the highest information gain
- Recognise that information gain is biased toward many-valued (ID-like) attributes, and how gain ratio fixes it
- Handle numeric features by binary thresholds, and know the Gini index as an alternative impurity
Support Vector Machines, Kernels & PCA
Max-margin hyperplane, kernel trick, dimensionality reduction via SVDThis Week 6 topic of COMP5318 Machine Learning and Data Mining at the University of Sydney covers three linear-algebra workhorses: the support vector machine, which separates two classes with the maximum-margin hyperplane supported by a handful of boundary points; the kernel trick, which lets that linear machine draw curved boundaries by working in a higher-dimensional feature space without ever building it; and PCA, an unsupervised method that finds the orthogonal directions of maximum variance via the SVD to reduce dimensionality and compress data.
- Write a separating hyperplane as w·x + b = 0 and the supporting planes at +1 and −1
- Compute the margin as 2/‖w‖ and see that maximising it means minimising ½‖w‖²
- Solve the support-vector equations to pin down w and b, then identify the support vectors
- Explain how the regularization constant C trades margin width against training-error tolerance
- State why the kernel trick works — K(x,y) = Φ(x)·Φ(y) computes an inner product without building Φ
- Evaluate the polynomial kernel (x·y + 1)^d and know how RBF's γ controls boundary smoothness
Neural Networks & Backpropagation
Perceptrons, sigmoid MLPs, gradient descent, the backprop update rulesThis chapter of University of Sydney COMP5318 Machine Learning and Data Mining shows how a network is built from simple neurons a = f(w·x + b), why a single perceptron is only a linear classifier (it cannot solve XOR), and how a sigmoid multilayer perceptron (MLP) is trained by gradient descent using backpropagation.
- Write a neuron as a = f(w.x + b) and name the roles of the weights, bias and activation
- Use the perceptron step activation and see why one unit draws a single linear boundary
- Explain why XOR is not linearly separable and needs a hidden layer
- Apply the perceptron learning rule w_new = w_old + e.x, b_new = b_old + e
- State the sigmoid s(z) = 1/(1 + e^-z) and its derivative s'(z) = o(1 - o)
- Run a forward pass through a small sigmoid MLP, hidden units first then the output
Deep Learning: CNN, RNN & Transformer
Convolution/pooling, LSTM gates, self-attention, positional encodingThis Weeks 8-9 topic of COMP5318 Machine Learning and Data Mining at the University of Sydney takes the neural-network foundations deep, across the three architectures the exam keeps returning to.
- Explain convolution as a small shared filter slid over an image, and compute a feature map by hand
- Use weight sharing and translation invariance to say why a CNN beats a dense net on images like MNIST
- Contrast max pooling and average pooling, and state the drawback of each
- Describe how an RNN carries a hidden state and why plain RNNs suffer vanishing gradients on long sequences
- Name the LSTM's input, forget and output gates and what each controls, and place a GRU as the lighter alternative
- Compare RNN and LSTM on computation and on their ability to capture long-range dependencies
Clustering
K-means, GMM/EM, hierarchical linkages, DBSCAN, cohesion vs separationThis Week 10 topic of COMP5318 Machine Learning and Data Mining at the University of Sydney moves from supervised prediction to unsupervised learning: grouping unlabelled data so that points inside a cluster are similar (high cohesion) and clusters are far apart (high separation).
- Define clustering as unsupervised grouping and explain cohesion vs separation as the quality goal
- Measure similarity with Euclidean, Manhattan and cosine distances, and know when to scale features
- Distinguish a cluster's centroid (the mean) from its medoid (the most central real point)
- Run the K-means loop — assign to nearest centroid, recompute the mean, repeat until centroids stop moving
- Explain why K-means minimises SSE, is sensitive to initialisation, and struggles with non-spherical or unequal clusters
- Describe GMM and the EM algorithm as a soft, probabilistic generalisation of K-means
Markov Models & HMMs
Markov chains, Forward algorithm (evaluation), Viterbi (decoding)Markov chains and Hidden Markov Models are the sequence-modelling topic of COMP5318 Machine Learning and Data Mining at the University of Sydney, sitting alongside the unit's other examinable methods (k-NN, Naive Bayes, decision trees, PCA, neural networks and clustering).
- State the first-order Markov assumption: the next state depends only on the current state, not the full history
- Read a transition matrix a_ij (row = from, column = to) and check that every row sums to 1
- Compute the probability of a state sequence: initial probability times one transition per step
- Identify the four parts of an HMM: hidden states, transition matrix A, emission matrix E, initial distribution A0
- Distinguish the three HMM problems: evaluation (Forward), decoding (Viterbi), learning (Baum-Welch / EM)
- Run the Forward algorithm (initialise, iterate with a SUM, terminate) to find P(observation sequence)
Reinforcement Learning
Rewards, discounting, optimal policy/value, Q-learning and Deep Q with experience replayThis chapter covers reinforcement learning (RL) from the Week 12 block of COMP5318 Machine Learning and Data Mining at the University of Sydney.
- Why RL differs from supervised learning: a scalar reward signal, not labelled targets, and actions that change the data seen next
- The Markov Decision Process tuple (states, actions, reward, transition probability, discount) and the agent-environment loop
- Rewards, return and the discount factor gamma: myopic near gamma=0, far-sighted near gamma=1
- The state-value V and action-value Q functions, and the optimal policy that maximises expected return
- The Bellman optimality equation, and solving a small deterministic MDP backward from the terminal state
- The Q-learning update rule: TD target, TD error, learning rate, and the max over next actions
This free study guide re-derives every core method and works each calculation by hand, matched to how COMP5318 is assessed at the University of Sydney: a 60% closed-book final exam alongside weekly Canvas quizzes and two group assignments. It turns the Machine Learning and Data Mining syllabus into reliable, method-by-method exam marks.
Worked example · free
Decision-tree information gain of a split
- +1Parent entropy: the node is 8 Buy and 8 No-buy (50/50), so H(S) = −0.5·log₂(0.5) − 0.5·log₂(0.5) = 1.0 bit (maximum uncertainty).
- +1Child A entropy (6 Buy, 2 No-buy): H = −0.75·log₂(0.75) − 0.25·log₂(0.25) = 0.75·0.415 + 0.25·2 = 0.811 bits; by symmetry child B (2 Buy, 6 No-buy) is also 0.811 bits.
- +1Weighted child entropy = (8/16)·0.811 + (8/16)·0.811 = 0.811 bits.
- +1Information gain = H(S) − weighted child entropy = 1.0 − 0.811 = 0.189 bits — positive, so the split is worth making; choose the attribute with the highest gain.
Key terms
- Supervised learning
- Learning from labelled input–output pairs to predict a target: classification when the target is a category, regression when it is a number.
- Unsupervised learning
- Finding structure in unlabelled data, e.g. clustering points into groups or reducing dimensions with PCA.
- Overfitting
- When a model fits the training noise so training error keeps falling while true (test) error rises; the best model sits at the lowest test error, not lowest train.
- Euclidean distance
- Straight-line distance √(Σ(aᵢ−bᵢ)²) between two feature vectors; features must be scaled first so no large-range feature dominates.
- k-Nearest Neighbour (kNN)
- A lazy classifier that labels a query by the majority class of its k closest training points; small k overfits, large k over-smooths.
- Naïve Bayes
- A probabilistic classifier picking the class that maximises P(class)·∏P(featureⱼ|class), assuming features are conditionally independent given the class.
- Entropy
- H(S) = −Σpᵢlog₂pᵢ, the impurity of a node in bits: 0 when pure, 1 for a two-class 50/50 split.
- Information gain
- The drop in entropy from a split, H(S) − Σ(|Sₖ|/|S|)H(Sₖ); a decision tree splits on the attribute with the highest gain.
- Support vector
- A training point lying exactly on an SVM's ±1 margin plane; only the support vectors determine the maximum-margin boundary.
- Principal Component Analysis (PCA)
- An unsupervised method that finds orthogonal directions of maximum variance for dimensionality reduction and compression — it ignores labels.
- Backpropagation
- Training a neural net by propagating error back: output δ = (t−o)o(1−o) for sigmoid, and each weight updates by Δw = η·δ·(source output).
- Regularization
- A penalty on the weights to curb overfitting: Ridge (L2) shrinks weights toward zero, while Lasso (L1) drives some exactly to zero for feature selection.
- Confusion matrix
- The 2×2 table of TP, FP, FN, TN from which accuracy, precision, recall and F1 are read; on imbalanced data prefer precision/recall over accuracy.
- Q-learning
- A reinforcement-learning update Q(s,a) ← Q + α[r + γ·maxₐ′Q(s′,a′) − Q] that learns action values from rewards, not labelled examples.
COMP5318 FAQ
Can AI help me study COMP5318?
Yes — used as a study aid, AI is well suited to a method-heavy unit like COMP5318 Machine Learning and Data Mining. Sia, AskSia's AI tutor, explains each method step by step: it can walk you through a kNN vote, a Naïve Bayes product, an entropy and information-gain calculation, or a single backpropagation step, and check your reasoning.
It is there to help you understand the material, not to complete your Canvas quizzes or assignments for you.
Where can I find past exam papers or practice for COMP5318?
Official past papers and sample exams for COMP5318 are released through Canvas and the University of Sydney library's exam-paper collection — always start there. This free guide adds a practice bank of exam-style problems with full worked solutions across the whole unit, and you can ask Sia to explain any step or generate similar practice so you can rehearse the method, not just read the answer.
What can Sia do that a textbook can't?
A textbook shows one worked example; Sia adapts to you. Ask it to re-explain a step a different way, vary the numbers so you can practise, or pinpoint where your working went wrong on a decision-tree or backpropagation question. Sia explains step by step and is a study aid — it will not sit your COMP5318 exam or complete your assessments, and it cannot promise a grade.
Is COMP5318 hard?
COMP5318 Machine Learning and Data Mining is a quantitative postgraduate unit at the University of Sydney: it assumes basic linear algebra, probability and competent programming, and it moves fast across many algorithms. Most students find the breadth — and the 40% exam hurdle — the real challenge rather than any single topic, so steady weekly work on the quizzes and the by-hand calculations pays off.
Confirm current prerequisites and details on Canvas and the handbook.
Is the COMP5318 exam open or closed book?
The final exam is closed book and paper-based, worth 60% of the unit, with 2 hours of writing time; a non-programmable calculator is the only permitted aid (no notes, laptops or phones). Answers are written in the exam booklet, and there is no coding in the exam. Confirm the exact date and venue on the Canvas exam timetable.
What are the COMP5318 hurdle requirements?
There are two hurdles at the University of Sydney: you must score at least 40% in the final exam or your final mark is capped at a maximum of 45, and you must reach an overall mark of at least 50 to pass the unit. Because the exam is 60% and hurdled, strong coursework alone cannot rescue a weak exam — always check the current rules on Canvas.
Do I need strong maths and programming for COMP5318?
The unit lists basic linear algebra, probability theory and competent programming in a high-level language as assumed knowledge, and Python (Jupyter) is used in the practicals and assignments. You do not need to be an expert, but comfort with vectors, probabilities and writing code will make COMP5318 Machine Learning and Data Mining much smoother — see the University of Sydney handbook for the official prerequisites.
Questions students ask in each COMP5318 chapter
- Is machine learning examined by calculation or by explanation in COMP5318?
- Both. The final is paper-based, 2 hours, closed book with only a non-programmable calculator, and mixes short-answer and True/False concept questions with small by-hand calculations. Foundations appear as quick items such as classifying a task as supervised or unsupervised, normalising a feature, or computing a Euclidean or Manhattan distance, so you are marked on method plus the correct final number plus a one-line reason. Chapter 01 · Foundations of Machine Learning & Data Mining
- Do I have to know both Euclidean and Manhattan distance for the exam?
- Yes. Short distance calculations appear in the k-NN style of question, and the paper may specify either metric, so practise both. Euclidean squares each coordinate difference then takes a square root; Manhattan sums the absolute differences. Because the exam is closed book with only a non-programmable calculator, the numbers are kept small enough to work by hand — always show the working, since method marks are awarded even if one slip changes the final vote. Chapter 02 · k-Nearest Neighbour & Rule-Based Classifiers
- Is linear regression fitted the same way as logistic regression?
- No — and the exam tests the difference. Linear regression fits a numeric-target line by least squares (minimising SSE), which has a closed form. Logistic regression is a two-class classifier: it runs the linear score through a sigmoid and chooses the weights that make the observed 0/1 labels most probable — maximum likelihood, solved iteratively. Writing 'logistic regression minimises SSE' is a common false statement. Chapter 03 · Linear & Logistic Regression, Regularization
- Why is Naïve Bayes called "naïve", and does the assumption break it?
- It is naïve because it assumes the features are independent of each other once you know the class, which is rarely true of real data. In practice the classifier still performs well and is very cheap: one pass to count the training data, then a product of likelihoods to predict. The assumption is what lets you multiply the per-feature likelihoods instead of estimating a full joint distribution, so it is a deliberate simplification rather than a flaw. Chapter 04 · Naïve Bayes & Model Evaluation
- How do I decide which attribute a decision tree splits on?
- Compute the information gain of every candidate attribute at that node and split on the one with the highest gain. Information gain is the parent entropy minus the weighted average of the child entropies, where each child is weighted by its share of the examples (|Sₖ|/|S|), not a plain average. Because a pure child has entropy 0, an attribute that produces a pure branch tends to win. Watch the bias: information gain favours many-valued, ID-like attributes that split data into near-unique singletons — those look perfect but only memorise the training set, which is why gain ratio or dropping ID columns is used. Chapter 05 · Decision Trees & Ensembles
- How do I tell which points are support vectors, and why do only they matter?
- Solve for the boundary first, then test each point against the supporting hyperplanes w·x + b = ±1. A point is a support vector only if it lies exactly on its class's line, i.e. yᵢ(w·xᵢ + b) = 1. Every other correctly classified point sits strictly beyond its margin (yᵢ(w·xᵢ + b) > 1). Only the support vectors touch the margin, so they alone pin the boundary in place — deleting a non-support-vector changes nothing, while deleting a support vector can move the boundary. That is why an SVM is defined by a handful of points, not the whole dataset. Chapter 06 · Support Vector Machines, Kernels & PCA
- Is neural networks examined by calculation or by explanation in COMP5318?
- Both, and usually by calculation. The final is paper-based, 2 hours, closed book with only a non-programmable calculator, and neural networks appear as short numeric items: run a forward pass through a small sigmoid network, take one backpropagation step to update a weight, count trainable parameters of a Dense network, or explain the vanishing-gradient problem in a sentence. Marks are awarded for the method and the correct final number, so always show each substitution. Chapter 07 · Neural Networks & Backpropagation
- Why is a CNN better than an ordinary (dense) neural network for images?
- A fully-connected net gives every pixel its own weight to every neuron — an enormous parameter count with no sense of locality and no reuse. A CNN builds in image structure: local receptive fields (a pixel matters most to its neighbours), weight sharing (one small filter reused everywhere, so far fewer parameters and less overfitting), and translation invariance (a feature is detected wherever it appears). That is why the standard answer to 'classify MNIST handwritten digits' is a CNN rather than an MLP or k-NN. Chapter 08 · Deep Learning: CNN, RNN & Transformer
- How is clustering different from classification?
- Classification is supervised — it is given class labels and learns to predict them. Clustering is unsupervised — there are no labels, so it can only group similar examples together, never 'predict a class'. That is why clustering quality is judged by internal measures such as cohesion and separation (or the silhouette coefficient), not by accuracy against labels, unless a separate ground-truth is explicitly provided for an external measure. Chapter 09 · Clustering
- What is the difference between the Forward and Viterbi algorithms?
- They share the same trellis and the same initialisation, but they answer different questions and use a different operator. Forward SUMS over all incoming paths and returns a probability P(observation sequence) - it evaluates how likely the observations are. Viterbi takes the MAX incoming path (and stores back-pointers) and returns a sequence of states - it decodes the single most likely hidden path. A quick check in the exam: if the question asks for a probability, use Forward's sum; if it asks which states, use Viterbi's max and trace the pointers back. Chapter 10 · Markov Models & HMMs
- What is the main difference between reinforcement learning and supervised learning?
- In supervised learning the model is trained on labelled examples and tries to match a given target for each input. In reinforcement learning there are no labels: the agent receives only a scalar reward signal from the environment, and its objective is to maximise expected cumulative (discounted) future reward. There are two further contrasts the exam rewards naming: the agent's own actions change the data (states) it sees next, and rewards can be delayed rather than immediate. This is a common 2-mark short-answer, so list two or three of these differences explicitly. Chapter 11 · Reinforcement Learning
How to study for the exam
Treat COMP5318 Machine Learning and Data Mining at the University of Sydney as a breadth unit assessed mostly by a 60% closed-book final: keep pace with the weekly Canvas quizzes, start the two group assignments early, and above all rehearse the by-hand calculations that recur on the paper — a distance, a kNN vote, a Naïve Bayes product, entropy and information gain, precision/recall/F1, a PCA judgement, a backpropagation step, an HMM Forward pass and a Q-learning update.
For each, name the method, do one clean calculation, and write the one-line reason; because the exam carries a 40% hurdle, practise touching every topic rather than perfecting one, and use Sia to explain any step you get stuck on so it lifts your WAM without doing the work for you.
Your AI Computer Science tutor for COMP5318
Stuck on a hard COMP5318 question? Sia is AskSia’s AI Computer Science tutor — ask any COMP5318 Machine Learning and Data Mining question and get a clear, step-by-step explanation grounded in how the course is actually taught and assessed. Read this whole study guide free, then take your hardest questions to Sia.