Code Monkey home page Code Monkey logo

pymc3_euss's Introduction

Tutorial: Probabilistic Programming with Python

EU Summer School, June 26, 2018

Binder

This intermediate-level course will provide students with hands-on experience applying practical Bayesian statistical modeling methods on real data. PyMC3 is a high-level Python library for building statistical models using probabilistic programming, and fitting them using modern Bayesian computational methods. I will provide an introduction to Bayesian inference and prediction, followed by a tutorial on probabilistic programming with PyMC3, including the use of Markov chain Monte Carlo (MCMC) and Variational Inference (VI), using real-world datasets. The last part of the course will focus on modeling strategies and how to avoid various pitfalls when applying Bayesian statistics to your own work. The course will assume familiarity with Python and with basic statistics (e.g. probability), but does not require previous experience with Bayesian methods or probabilistic programming.

Syllabus

Basic Bayesian Inference

  • Bayesian vs. frequentist world views
  • Bayesian inference in three steps
  • Probability distributions
  • Parameter estimation model

Introduction to PyMC3

  • Variable types
  • Probability models
  • Simple case studies

Markov Chain Monte Carlo

  • Metropolis sampling
  • Gradient-based sampling methods

Model Building with PyMC3

  • Specifying priors and likelihoods
  • Deterministic variables
  • Factor potentials
  • Custom variables
  • Step methods
  • Generalized linear models
  • Missing Data

Case Studies

  • Comparing two groups with continuous outcomes
  • Comparing two groups with binary outcomes

Model Checking and Output Processing

  • Storage backends
  • Convergence diagnostics
  • Goodness of fit
  • Plotting and summarization

Hierarchical Models

  • Partial pooling
  • Non-centered parameterization
  • Contextual effects

Approximation Methods

  • MAP
  • Variational inference
  • ADVI

Software Installation

Running PyMC3 requires a working Python3 interpreter, preferably Python 3.6. A complete Python installation for Mac OSX, Linux and Windows can most easily be obtained by downloading and installing the free Anaconda Python Distribution by ContinuumIO. If possible, please have your Python environment ste up prior to the course.

PyMC3 can be installed using conda, a package management tool that is bundled with Anaconda. PyMC3 also depends on several third-party Python packages which will be automatically installed when installing via conda. The four required dependencies are: Theano, NumPy, SciPy, Matplotlib, and joblib. To take full advantage of PyMC3, the optional dependencies seaborn, pandas and Patsy should also be installed. You can install PyMC3 and its dependencies by cloning this repository:

git clone https://github.com/fonnesbeck/PyMC3_EUSS.git

Then move into the directory created by the clone, and install the required packages using conda:

cd PyMC3_EUSS
conda env create -f environment.yml

This will create a virtual environment called pymc_tutorial that includes the dependencies for PyMC3 that is completely separate from any other Python installations you may have on your machine. To activate this environment to run the course materials, you can run the following command from the terminal:

source activate pymc_tutorial

If you would rather not install the software yourself, you can use the MyBinder.org link at the top of the page to run the course materials on a remote server

You can update the course materials at any time by pulling from the course repository. From your course directory, type:

git pull

Note that this will overwrite any changes you have made to notebooks that need to be updated.

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.