Welcome to the world of probabilistic machine learning! If you’re eager to create amazing figures as seen in the books Probabilistic Machine Learning: An Introduction and Probabilistic Machine Learning: Advanced Topics, you’re in the right place. In this guide, we will break down the steps to reproduce these figures using Python, along with troubleshooting tips to help you overcome common challenges.
Prerequisites: Install the Necessary Libraries
The code relies heavily on standard Python libraries such as numpy, scipy, matplotlib, and sklearn. Moreover, you might encounter JAX, TensorFlow 2, and Torch within certain sections. To begin your journey, ensure you have these libraries installed in your environment:
- JAX
- TensorFlow 2
- Torch
- probml-utils for utility code
Running Notebooks in Google Colab
Google Colab is an excellent platform as it comes pre-installed with most libraries you need and offers free access to GPUs and TPUs. To run notebooks in Colab, follow these steps:
- Open the desired notebook from the provided links:
- Change the notebook URL from
github.comtogithubtocolab.comas explained here. - For Chrome users, utilize the Open in Colab Chrome extension for a seamless experience.
Running Notebooks Locally
If you prefer to run notebooks locally, ensure you have the predisposed installations. Then, install additional requirements through one of the following methods:
- Option 1: Execute
bash pip install -r https://raw.githubusercontent.com/probml/pml/master/requirements.txt - Option 2: Download requirements.txt and execute
bash pip install -r requirements.txt - Option 3: Clone the repository with
git clone --depth 1 https://github.com/probml/probml.gitand install packages manually.
To save figures, set up your environment variables:
# export FIG_DIR=teamspacestudio/this_studio/figures
import os
os.environ['FIG_DIR'] = 'teamspacestudio/this_studio/probml/notebooks/figures'
os.environ['DUAL_SAVE'] = '1' # both pdf and png
Using Cloud Computing
For enhanced computing capabilities beyond Colab, consider platforms like Lightning AI which simplifies development and allows for effortless GPU scaling with a click. Alternatively, explore Google Cloud Platform for extensive power and flexibility.
Troubleshooting Common Issues
While navigating through your project, you may encounter some bumps along the way. Here are troubleshooting ideas:
- If you’re having trouble with library installations, ensure your Python version is compatible.
- Check internet connectivity for accessing data from repositories.
- For issues with saving figures, confirm that the directory paths are correctly set in your environment variables.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.
Conclusion
Now you are equipped with the knowledge to reproduce figures from these fascinating books! Dive into the world of probabilistic machine learning and enjoy the process of learning and creating.

