Probabilistic Machine Learning: An Introduction

by Kevin Patrick Murphy.
MIT Press, March 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 = ""

Downloads since 2021-01-01. download stats shield

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 click on any link labeled and it will open up the colab for chapter x; the cursor should 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 10 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 run the code for you. (It should automagically install any missing packages as well, although you may need to run the cell twice to make this work.)

The code for most figures is stored in individual files in the scripts directory. You can run these locally (on your laptop), but it's often faster to run in colab (especially for demos that use a GPU). To do this, just type `%run`. You can also edit the file in colab, and then rerun it. Note, however, that changes to local files will not be saved beyond the current colab session. (A better, but more complex, approach is to use VScode to ssh into the colab machine, see this page for details.)

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, many chapters have supplementary code / material (for example, here). These will continue to be updated even after the book is published (contributions welcome!).




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