Course · Python code

Python code that reproduces the figures

One module per chapter of Murphy, Probabilistic Machine Learning: An Introduction (2022), with one function per figure, linked to the lecture notes. The code is written for this course with numpy, scipy, pandas, matplotlib, scikit-learn and PyTorch.

How to run it

  1. Install Python 3 with numpy, scipy, pandas, matplotlib, scikit-learn and PyTorch (CPU is enough).
  2. Run one chapter with python3 ch11_linear_regression.py, list its figures with --list, make one with --fig 11.1, or run every chapter with python3 make_all.py --figures.

Data come from scikit-learn's bundled data sets, small files in data/, and simulation; slow results are cached locally. Each figure is written to img/chNN/ as PNG, SVG and PDF. Shared helpers are in common.py.

Chapter 1. Introduction

Module: ch01_introduction.py · Notes: Introduction

11 figures

Chapter 2. Probability: Univariate Models

Module: ch02_probability_univariate.py · Notes: Probability: Univariate Models

25 figures

Chapter 3. Probability: Multivariate Models

Module: ch03_probability_multivariate.py · Notes: Probability: Multivariate Models

13 figures

Chapter 4. Statistics

Module: ch04_statistics.py · Notes: Statistics

27 figures

Chapter 5. Decision Theory

Module: ch05_decision_theory.py · Notes: Decision Theory

15 figures

Chapter 6. Information Theory

Module: ch06_information_theory.py · Notes: Information Theory

5 figures

Chapter 7. Linear Algebra

Module: ch07_linear_algebra.py · Notes: Linear Algebra

9 figures

Chapter 8. Optimization

Module: ch08_optimization.py · Notes: Optimization

31 figures

Chapter 9. Linear Discriminant Analysis

Module: ch09_linear_discriminant_analysis.py · Notes: Linear Discriminant Analysis

13 figures

Chapter 10. Logistic Regression

Module: ch10_logistic_regression.py · Notes: Logistic Regression

16 figures

Chapter 11. Linear Regression

Module: ch11_linear_regression.py · Notes: Linear Regression

25 figures

Chapter 12. Generalized Linear Models

Module: ch12_generalized_linear_models.py · Notes: Generalized Linear Models

4 figures

Chapter 13. Neural Networks for Tabular Data

Module: ch13_neural_networks_tabular.py · Notes: Neural Networks for Tabular Data

19 figures

Chapter 14. Neural Networks for Images

Module: ch14_neural_networks_images.py · Notes: Neural Networks for Images

28 figures

Chapter 15. Neural Networks for Sequences

Module: ch15_neural_networks_sequences.py · Notes: Neural Networks for Sequences

17 figures

Chapter 16. Exemplar-based Methods

Module: ch16_exemplar_based_methods.py · Notes: Exemplar-based Methods

16 figures

Chapter 17. Kernel Methods

Module: ch17_kernel_methods.py · Notes: Kernel Methods

21 figures

Chapter 18. Trees, Forests, Bagging, and Boosting

Module: ch18_trees_forests_boosting.py · Notes: Trees, Forests, Bagging, and Boosting

18 figures

Chapter 19. Learning with Fewer Labeled Examples

Module: ch19_learning_with_fewer_labels.py · Notes: Learning with Fewer Labeled Examples

15 figures

Chapter 20. Dimensionality Reduction

Module: ch20_dimensionality_reduction.py · Notes: Dimensionality Reduction

38 figures

Chapter 21. Clustering

Module: ch21_clustering.py · Notes: Clustering

27 figures

Chapter 22. Recommender Systems

Module: ch22_recommender_systems.py · Notes: Recommender Systems

13 figures

Chapter 23. Graph Embeddings

Module: ch23_graph_embeddings.py · Notes: Graph Embeddings

10 figures