• Stars
    star
    269
  • Rank 152,662 (Top 4 %)
  • Language
    Jupyter Notebook
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Statistical Rethinking (2nd Ed) with Tensorflow Probability

Statistical Rethinking (2nd Edition) with Tensorflow Probability

This repository provides jupyter notebooks that port various R code fragments found in the chapters of Statistical Rethinking 2nd Edition by Professor Richard McElreath to python using tensorflow probability framework.

Note - These notebooks are based on the 8th December 2019 draft. I will update the notebooks once the book is released.

Misc Notes

  • Why Tensorflow Probability ? There are many great probabilitic frameworks (PPLs) out there. I especially like Numpyro & PyMC3. There are 2 main reasons why I chose to do this exercise in tfp.

    • First and main reason is to not use the magic of the libraries. Sometimes higher level libraries hide the details which are necessary for one to truly understand the subject. As a matter of fact, working with TFP has resulted in me becoming more appreciable of these high level libraries as indeed they not only provide great helpers but make the code easy to read and reuse.
    • Second is that I have other investments in Tensorflow ecosystem so am not keen on switching to pyTorch even though I really like what Pyro team has done.

    For production use, I strongly recommend that one must use these higher level libraries i.e. Numpyro, PyMC3

  • What worked ? Well of course this book is the best there is in this area. The community is also great. I got quick responses from tensorflow probability team whenever I asked questions on tfp google group.

  • What was hard ? It may be tad bit subjective because I am challenged when it comes to manipulating shapes (high dimensional arrays). I find numpy to be difficult and tensorflow is way more harder when it comes to working with multi-dimensional arrays. This is one of the main problems I have faced and continue to face. Another problem is that the stack trace generated by TFP can be really difficult to understand. This mostly is the side effect of graphs that make debugging difficult. Quite often as long as I used only 1 chain things would work but working with multiple chains require that you pay special attention to the shapes/batches of the various tensors/distributions.

  • Visualization I have made use of arviz and in order to do that I converted the output of various sampling procedures to the format/structure required by it. This made me learn and discover xarray. It was really worth doing it and made it easy to plot the graphs.

Chapters

If you prefer the readonly view of notebooks (html pages) then use this link - https://ksachdeva.github.io/rethinking-tensorflow-probability/

If you want to run the notebooks locally -

# install the requirements
pip install -r requirements.txt
# install jupyter in your virtual environment
pip install -r requirements-extra.txt
# do the dev setup (as some common code resides in rethinking module)
pip install -e .

If you prefer to run the notebooks in binder then click here Binder

Clicking on the links will open the notebooks in Google Colab

Acknowledgements

My immense gratitude goes to Professor Richard McElreath for writing such a wonderful book. His method of teaching has made somewhat difficult subject of Bayesian Statistics approachable, interesting and to some extent fun as well. We need more educators like you Sir !.

Another person I want to thank is Du Phan (https://github.com/fehiepsi). He is the main author of Numpyro, a great framework to do Bayesian Analysis. He has ported Statsical Rethinking (2nd Ed) to Numpyro and his notebooks were not only insipirational but were also of great help to me in creating graphs. I borrowed most of his code fragments when it came to plotting the figures using matplotlib.

More Repositories

1

angular-swiper

Angular directive for nolimits4web/Swiper
HTML
197
star
2

opencv-mtcnn

An implementation of MTCNN Face detector using OpenCV's DNN module
C++
68
star
3

angular2-swing

angular 2 component for the swing library (https://github.com/gajus/swing)
TypeScript
62
star
4

angular2-swiper

Angular 2 Swiper component that wraps http://idangero.us/swiper
TypeScript
55
star
5

tensorflow-cc-examples

Tensorflow examples written in C++
CMake
43
star
6

dlib-to-tf-keras-converter

A set of scripts to convert dlib's face recognition network to tensorflow, keras, onnx etc
Jupyter Notebook
37
star
7

YATODO

Yet Another TODO application
35
star
8

langchain-graphrag

GraphRAG / From Local to Global: A Graph RAG Approach to Query-Focused Summarization
Python
29
star
9

ionic2-code-push-example

Example of how to use Microsoft CodePush with ionic2 and ionic-native
CSS
25
star
10

scikit-nni

AutoML - Hyper parameters search for scikit-learn pipelines using Microsoft NNI
Python
23
star
11

angular2-swiper-example

Example of how to use Swiper in angular 2 application
TypeScript
21
star
12

tiny-imagenet-tfds

tiny-imagenet dataset downloader & reader using tensorflow_datasets (tfds) api
Python
20
star
13

hyperledger-fabric-example

An example project to support blog posts on Bootstrapping a Hyperleder Fabric network
TypeScript
16
star
14

ngCordova-typescript-demo

Demo of Ionic 1.X using ngCordova written in Typescript
CSS
9
star
15

angular2-swing-example

Example showing how to use angular2-swing module
TypeScript
9
star
16

ftdi

GoLang bindings for FTDI MPSSE library (D2XX)
C
8
star
17

angular2-progressbar

Angular 2 component for progressbar.js
TypeScript
7
star
18

firebase-custom-auth-example

Custom authentication example for Firebase & AngularFire2
JavaScript
7
star
19

rxjs-zone-operators

Reactive extensions for Zones
TypeScript
5
star
20

deeplearn-examples

Examples using Deeplearn.js
TypeScript
5
star
21

tensorflow-cc-sdk-generator

Set of scripts to generate a CMake enabled tensorflow c++ SDK
Shell
4
star
22

tfjs-data-mnist

API for MNIST dataset built using tfjs-data
TypeScript
3
star
23

idea-manager

Record and share your ideas !
JavaScript
3
star
24

agilePLM

node module for Oracle Agile PLM
JavaScript
3
star
25

caf-playground

C++ Actor Framework Playground
Jupyter Notebook
3
star
26

face-embeddings-generator

A simple tool to generate face embeddings using dlib and/or facenet networks
Python
3
star
27

cordova-plugin-rx-ble

Cordova Plugin for Bluetooth Low Energy
Java
3
star
28

od-loss-exp

Some work to compare various object detection loss functions
Jupyter Notebook
3
star
29

RxSwiftMQTT

Reactive Extensions for MQTT in Swift
Swift
2
star
30

ionic2-code-push

CodePush support in Ionic 2 applications
TypeScript
2
star
31

angular2-store-saga-example

Example application showing how to use @ngrx/store & store-saga
JavaScript
2
star
32

angular2-progressbar-example

Example for using angular2-progressbar component
TypeScript
2
star
33

pkijs-node-example

An example app showing how to use PKIJS with nodejs
TypeScript
2
star
34

pc-ble-driver-js-examples

Examples of how to use pc-ble-driver-js node module
TypeScript
1
star
35

ml-in-hurry

Machine Learning in Hurry
Jupyter Notebook
1
star
36

node-docker-compose

Docker Compose API (not wrapper on python application) for NodeJS
TypeScript
1
star
37

tfjs-react

React components for tensorflow.js
TypeScript
1
star
38

Google-App-Engine-experiments

This repository contains various App Engine applications
Python
1
star