Machine Learning Lab

Find principal components, run k-means and EM step by step, tame overfitting with ridge and lasso, and compare kNN, trees, naive Bayes, SVMs and boosting.

About the Machine Learning Lab

The Machine Learning Lab covers the classical algorithms that still do most of the work in industry, and that interviews still ask about: principal component analysis, clustering, regularised regression, nearest neighbours, decision trees, support vector machines and ensembles.

Each experiment runs on a small two-dimensional dataset, so you can see every point and every boundary. You can step through k-means and EM one iteration at a time, raise a polynomial's degree until it overfits and then rein it in with ridge or lasso, or move the cost C of an SVM and watch the support vectors change.

It goes with the Machine Learning Techniques course and suits undergraduates taking a first ML course, as well as anyone who has used these models from a library and wants to know what they are actually doing.

Experiments in this lab

  1. PCA: variance and error: Turn a line through a cloud of points: the variance it keeps and the error it loses always add up.
  2. Feature maps and kernel PCA: Add a feature and two rings that no straight line can separate fall apart.
  3. K-means: Assign, average, repeat: step through Lloyd’s algorithm, compare starts and find the elbow.
  4. Gaussian mixtures and EM: Soft clustering: responsibilities, weighted refits and a likelihood that never falls.
  5. Regression, ridge and lasso: Raise the degree until it overfits, then tame it with an L2 or L1 penalty.
  6. k-nearest neighbours: Vote among the closest points and watch k trade wiggles for smoothness.
  7. Decision trees: Axis-aligned questions chosen by information gain, and what depth does to new data.
  8. Naive Bayes vs logistic: A generative and a discriminative model on the same data: whose boundary bends?
  9. Support vector machines: The widest street, support vectors, the cost C and the RBF kernel.
  10. Bagging, forests and boosting: Many deep trees voting, or many stumps added one at a time.
  11. Classification losses: 0-1, hinge, logistic, exponential and perceptron losses on one margin axis.