Module 7: Machine Learning with Spark
Overview
Machine learning is where large datasets bite hardest. This module looks at how data can be big for ML (many observations, many features, or both) and the strategies for coping: reducing the data, faster algorithms, specialised hardware, and distributed training with data and model parallelism. It also covers model compression for serving large models. The hands-on part times scikit-learn as data grows, then builds models with Spark MLlib.
Estimated time: about 3 hours (1.5 hours lecture and group activities, 1.5 hours hands-on)
Learning objectives
By the end of this module, you should be able to:
- Identify where in the ML pipeline large data causes problems, and how both many observations and many features make data big for ML.
- Choose a sensible first strategy for a large ML problem, such as downsampling, feature selection or dimensionality reduction, before investing in more compute.
- Explain distributed training: data vs model parallelism, centralised vs decentralised communication, and synchronous vs asynchronous parameter updates.
- Describe the four main model compression techniques: quantisation, pruning, knowledge distillation and efficient architectures.
- Build and evaluate a model with Spark MLlib using transformers, estimators and pipelines.
Before class
Make sure PySpark works on your machine: follow Python environment setup and run the check-setup notebook.
Prerequisites: Module 6 (Spark DataFrames), and basic machine learning: training and test sets, fitting and evaluating a model in scikit-learn.
The notebook uses the Kaggle Expedia dataset; see data/README.md for how to get it.
Lecture slides
Hands-on
Spark notebooks fail with UnsupportedClassVersionError or Java gateway process exited when Java is missing or too old. PySpark 4 needs Java 17 or later. See Python environment setup → Troubleshooting.
ML with Large Datasets
Training time with scikit-learn as data grows, then random forests with Spark MLlib.
Exercises
To be added.