Home / Study together / Weeks 1-4 together
MLF + MLT, weeks 1-4, learned together
One braided path through both courses, so each idea arrives just before you need it.
Why learn them together?
Imagine two friends building a treehouse. One (MLF) makes the tools: saws, hammers, rulers. The other (MLT) builds the treehouse and keeps shouting, "Now I need a saw!" If the second friend starts before the saw exists, they get stuck. If the first friend makes every tool before anyone builds anything, you forget why you made them.
So we braid: make a tool, use it straight away, make the next tool, use that. Weeks 1 to 4 of the two courses fit together almost perfectly this way.
Here is the dependency map. An arrow means "you need the left idea to understand the right one".
| MLF idea (the tool) | When MLT uses it (the treehouse) |
|---|---|
| Week 1: vectors, length, distance, dot product | MLT W1: data points are vectors; W3: k-means uses distance; W2: kernels are dot products |
| Week 2: derivative = 0 at the best point | MLT W3: the k-means centre is the mean; W4: MLE; Bayes |
| Week 3: projection ("closest point = perpendicular drop") | MLT W1: PCA's reconstruction is a projection |
| Week 4: eigenvalues and eigenvectors | MLT W1: principal components are eigenvectors; W2: kernel PCA |
| (later) MLF W5 symmetric/PSD, W6 SVD | deepens MLT W1 (covariance is symmetric PSD; PCA = SVD) and W2 (valid kernels are PSD) |
| (later) MLF W10 to W12 probability, MLE, EM | MLT W4 (MLE, Bayes, GMM, EM) uses them; this page gives you a first taste |
Quiz 1 for both courses covers weeks 1 to 4. MLF Quiz 1 papers test the intro, calculus, least squares/projection and eigenvalues. MLT Quiz 1 papers test PCA, kernel PCA, k-means, MLE, Beta-Bernoulli and GMM/EM. If you follow this page, you are preparing for both Quiz 1s at once.
The braided plan
Nine sessions. Each one is a lesson on this site; times are rough. Do them in this order.
| # | Session | Read | Why now | Time |
|---|---|---|---|---|
| 1 | What is ML, and vectors | MLF week 1 | everything is built from vectors and dot products | 60 to 90 min |
| 2 | The setup of PCA (stop after the covariance matrix) | MLT week 1, up to "Idea 1: The setup" | you now see why we want projections and eigenvectors, so the next two sessions have a purpose | 40 min |
| 3 | Calculus | MLF week 2 | derivative = 0 is needed for k-means and MLE | 70 to 90 min |
| 4 | Matrices, projection, least squares | MLF week 3 | projection is half of PCA | 90 min |
| 5 | Eigenvalues and eigenvectors | MLF week 4 | eigenvectors are the other half of PCA | 80 min |
| 6 | PCA, finished | MLT week 1 | the payoff: it should all click | 80 min |
| 7 | Kernel PCA | MLT week 2 | PCA only uses dot products, so swap them for kernels | 80 min |
| 8 | k-means | MLT week 3 | uses distance (S1) and "mean minimises squared distance" (S3) | 80 min |
| 9 | MLE, Bayes, GMM and EM | MLT week 4 | uses derivative = 0 (S3); gives the first taste of MLF's probability weeks | 110 min |
Two tips: after each session do its "Your turn" problems and the quick quiz; and tick "Mark this week as done" at the bottom of each lesson so the home page keeps your progress.
Four braided problems (solve them, then check)
Each of these is one problem seen through both courses. Try to answer before opening the solution.
In MLT week 1 the data points were centred and had first principal component . (a) Write the projection matrix onto that line (MLF week 3). (b) Use to reconstruct the centred point and find the reconstruction error. (c) Say why this equals the squared distance from to the line .
Need a hint?
since .
Show the full solution
(a) . Check: , , trace (rank 1). (b) . Error vector , squared length . (c) The reconstruction is the projection onto the line, i.e. the closest point on the line, so the error is the squared perpendicular distance from the point to the line. (The other centred points: lies on the line so its error is 0, and has error by symmetry. The average equals the discarded eigenvalue .)
The covariance matrix is . Without solving a quadratic, use the trace and determinant facts from MLF week 4 to find its eigenvalues, then give the variance explained by PC1.
Need a hint?
Sum of eigenvalues = trace; product = determinant.
Show the full solution
Trace , determinant . We need two numbers with sum and product : and . So and . Variance explained by PC1 . Note the trace is the total variance: , the sum of the two feature variances . (Eigenvector for 9: .)
(a) For the numbers find the value that minimises . (b) Why is that the k-means centre update? (c) A coin shows 7 heads and 3 tails; find the that maximises .
Need a hint?
Differentiate and set to zero in both.
Show the full solution
(a) . (b) In k-means, for fixed cluster members the best centre minimises the sum of squared distances, which by (a) is the mean of the members; so the update step moves each centre to the mean. (c) Maximise : , the MLE. The same move, "set the derivative to zero", solved three different problems.
Take and . (a) Compute the dot product (MLF week 1). (b) Compute the polynomial kernel . (c) Verify it with the feature map .
Need a hint?
A kernel is a dot product after lifting.
Show the full solution
(a) . (b) . (c) , : dot product ✓. So the kernel is exactly the week-1 dot product, taken in a bigger space, without ever computing .
What each MLF idea becomes in MLT (cheat-sheet)
| MLF idea | New name in MLT | One-line check |
|---|---|---|
| Distance | k-means assignment; Euclidean distance | nearest centre = smallest squared distance |
| Dot product | kernel | Gram matrix must be PSD |
| Derivative | MLE; k-means centroid = mean; ridge/least-squares solutions | set |
| Projection matrix | PCA reconstruction | error discarded eigenvalues |
| Eigenvalues of a symmetric matrix | variances of the principal components | trace total variance |
| Rank | number of non-zero PCA eigenvalues | data on a line one non-zero |
| Least squares | linear regression (MLT week 5) | residual columns |
Short on time?
3-day crash version (Quiz 1 only): Day 1: MLF W2 ("Idea 3" and "Idea 4" only: gradient, linear approximation, directional derivative) + MLF W3 (projection and least squares). Day 2: MLF W4 + MLT W1. Day 3: MLT W3 (k-means) + MLT W4 (Beta posterior, EM step). Finish each day with that week's quick quiz and real exam questions.
7-day version: follow the nine sessions, two per day, with the real-question pages on Days 5 to 7.
When you finish a lesson, open Practise with real exam questions at its bottom. When you finish all nine, go to the Past papers and sit one full Quiz 1 paper per subject under a timer.
Next: weeks 5 to 8 together, weeks 1 to 8 together or weeks 1 to 12 together. All four plans are listed on the Study together page.