Probabilistic Machine Learning: An Introduction

by Kevin Patrick Murphy.
MIT Press, February 2022.

Book cover

Key links

If you use this book, please be sure to cite

 author = "Kevin P. Murphy",
 title = "Probabilistic Machine Learning: An introduction",
 publisher = "MIT Press",
 year = 2022,
 url = ""

Table of contents

TOC 2021-07-20

Code accompanying the book

Code to recreate all the figures can be found in a series of colabs, one per chapter, stored here. When reading the pdf version of the book, you can right click on any link labeled and it will open up the colab for chapter x; the cursor should also scroll down to the cell for figure y. Once you get there, click on the button labeled 'setup' and it will install any necessary code. (The first time you do this it may take about 30 seconds, but subsequent setups for other cells in the same chapter should be faster, even if they open in a new tab.) After setup, click on the following cell and it will show the source code in the colab editor, and run it for you.

The code for each figure is stored in a separate file, either in the scripts directory, or the notebooks directory. In the former case, you can click on the 'show source code' button in the colab to open the source code inside the colab editor; you can then make changes (e.g., to the parameters or data), and rerun it. Note, however, that changes to local files will not be saved beyond the current colab session. In the latter case, you can click on the 'open colab' button, and it will open the source notebook in a new tab, which can be edited in the usual way. (Scripts can also be run locally on your laptop, but you may need to install certain packages, and some may be slow without a GPU. In general it is easier to do everything inside of colab.)

There are also some inline links to code in the body of the book, labeled; these refer to demos that are not associated with any figure. Clicking on these links behaves in a similar way to the figure code (opening a tab for the appropriate colab cell). In addition to the above, there are various forms of supplementary code / material associated with each chapter, such as additional jupyter notebooks and tutorials. These will continue to be updated even after the book is published.



I would like to thank the following people for helping with this book.