Git Product home page Git Product logo

pyprobml's Introduction

pyprobml

Python 3 code to reproduce the figures in the book series Probabilistic Machine Learning by Kevin Patrick Murphy. This is work in progress, so expect rough edges! (Some demos use code from our companion JAX State Space Library.)

Running the notebooks

The scripts needed to make all the figures for each chapter are automatically combined together into a series of Jupyter notebooks, one per chapter.

In addition to the automatically generated notebooks, there are a series of manually created notebooks, which create additional figures, and provide supplementary material for the book. These are stored in the notebooks repo, since they can be quite large. Some of these notebooks use the scripts mentioned above, but others are independent of the book content.

The easiest way to run these notebooks is inside Colab. This has most of the libraries you will need (e.g., scikit-learn, JAX) pre-installed, and gives you access to a free GPU and TPU. We have a created a intro to colab notebook with more details.

Running scripts in colab

The easiest way to run individual scripts is inside Colab. Just cut and paste this into a code cell:

pip install superimport 
git clone --depth 1 https://github.com/probml/pyprobml  &> /dev/null # THIS CODEBASE

Note: The superimport library will automatically install packages for any file which contains the line `import superimport'.

Then run a script from a cell like this:

%run pyprobml/scripts/softmax_plot.py

To edit a file locally and then run it, follow the example below.

# Make sure local changes to file are detected by runtime
%load_ext autoreload
%autoreload 2

file = 'pyprobml/scripts/softmax_plot.py' # change this filename as needed
from google.colab import files
files.view(file) # open editor

%run $file

To download and run code from github, follow the example below. (Note the raw in the URL.)

!wget -q https://raw.githubusercontent.com/probml/pyprobml/master/scripts/softmax_plot.py
%run softmax_plot.py

Running the scripts locally

We assume you have already installed JAX and Tensorflow and Torch, since the details on how to do this depend on whether you have a CPU, GPU, etc.

For the remaining python packages, do this:

pip install superimport 
git clone --depth 1 https://github.com/probml/pyprobml  &> /dev/null # THIS CODEBASE

Note: The superimport library will automatically install packages for any file which contains the line `import superimport'.

To manually execute an individual script from the command line, follow this example:

python3 pyprobml/scripts/softmax_plot.py 

This will run the script, plot a figure, and save the result to the pyprobml/figures directory.

Running scripts for vol 2

Some demos for vol 2 use JSL (Jax State-space Library). This requires extra packages, see these installation instructions. Then you can run the pyprobml version of the JSL demos like this

%run pyprobml/scripts/kf_tracking_demo.py # colab
python3 pyprobml/scripts/kf_tracking_demo.py # locally

GCP, TPUs, and all that

When you want more power or control than colab gives you, you should get a Google Cloud Platform (GCP) account, and get access to a TPU VM. You can then use this as a virtual desktop which you can access via ssh from inside VScode. We have created various tutorials on Colab, GCP and TPUs with more information.

How to contribute

See this guide for how to contribute code.

Metrics

Stargazers over time

GSOC 2021

For a summary of some of the contributions to this codebase during Google Summer of Code 2021, see this link.

Acknowledgements

I would like to thank the following people for contributing to the code (list autogenerated from this page):

murphyk mjsML Drishttii Duane321 gerdm animesh-007 Nirzu97 always-newbie161 karalleyna nappaillav jdf22 shivaditya-meduri Neoanarika andrewnc Abdelrahman350 Garvit9000c kzymgch alen1010 adamnemecek galv krasserm nealmcb petercerno Prahitha khanshehjad hieuza jlh2018 mvervuurt TripleTop
murphyk mjsML Drishttii Duane321 gerdm animesh-007 Nirzu97 always-newbie161 karalleyna nappaillav jdf22 shivaditya-meduri Neoanarika andrewnc Abdelrahman350 Garvit9000c kzymgch alen1010 adamnemecek galv krasserm nealmcb petercerno Prahitha khanshehjad hieuza jlh2018 mvervuurt TripleTop

pyprobml's People

Contributors

a-fakhri avatar abdelrahman350 avatar adamnemecek avatar alenm10 avatar always-newbie161 avatar andrewnc avatar animesh-007 avatar ashishpapanai avatar drishttii avatar duane321 avatar galv avatar garvit9000c avatar gerdm avatar hieuza avatar jlh2018 avatar johnfearns22 avatar karalleyna avatar krasserm avatar kzymgch avatar mjsml avatar murphyk avatar mvervuurt avatar nappaillav avatar nealmcb avatar neoanarika avatar nirzu97 avatar petercerno avatar prahitha avatar raymondyeh07 avatar shivaditya-meduri avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.