GithubHelp home page GithubHelp logo

corriebar / bayesian-workflow-with-pymc Goto Github PK

View Code? Open in Web Editor NEW
36.0 3.0 9.0 104.21 MB

Repository with code, notebook and slides for my talk at PyConDE & PyData Berlin 2019

Jupyter Notebook 99.60% Python 0.38% Makefile 0.02%

bayesian-workflow-with-pymc's Introduction

Bayesian Workflow with PyMC and ArviZ

Repository with code and notebook for my talk at PyConDE & PyData Berlin 2019.

The slides for the talk can be found here.

Setup

I'm using pipenv with Python 3.7 (the code might also work with other Python 3 versions but then you'll need to change the version in the Pipfile). To install pipenv, run

pip install pipenv

Then install the necessary packages, using

cd Bayesian-Workflow-with-PyMC
pipenv install

To activate the environment and start the notebooks from it, run

pipenv shell
python -m ipykernel install --user --name=$(basename $(pwd))
jupyter lab
# or jupyter notebook

Then, inside jupyter, pick the according kernel for the notebooks.

Preprocessing

To download the shapefiles and preprocess the data, run

make data

Data

The data used in the notebooks and for the talk is by Europace AG and not in the Repository. I instead included a data set of rental offers that I scraped from Immoscout24. A more detailed description of how I scraped the data etc can be found here. To use the rental data in the notebooks, you can change

d, zip_lookup, num_zip_codes = load_data(kind="prices")   

to

d, zip_lookup, num_zip_codes = load_data(kind="rents")

bayesian-workflow-with-pymc's People

Contributors

corriebar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bayesian-workflow-with-pymc's Issues

PyMCon 2020

Hi!

As you may have already seen on Twitter or on PyMC Discourse, we are planning a virtual conference for the PyMC community. All the information is available in the Discourse post.

We are currently looking for conference chairs and volunteers and would be very grateful if you could share the word! We also want to encourage you to, if you are interested and available, apply to be a conference chair.

How does log-transformation change the params?

Since the model will predict the log sqm price, the interpretation of the parameters also changes.

Make sure to understand, how to interpret

  • intercept (geometric mean)
  • slope (multiplicative change)
  • sigma

Hierarchical Model

Implement a basic hierarchical model with varying intercept and slope parameter, again only one predictor (living_space)

  • naive implementation hierarchical model
  • smarter implementation hierarchical model

Question: Using multivariate normal distribution?

Open data set

The talk will use proprietary data, but would be nice to have the same analysis with some immoscout data.

  • Link Immo Scout repo
  • Make Immoscout data accessible somewhere

Modularize scripts

The scripts could probably be enhanced by using more functions.

In particular, when using the same functions for the two data sets.

Implement Base Models

A few different variants of base models are needed:

  • 1. intercept-only normal-model
  • 2. intercept-only t-student model
  • 3. linear model (with predictor living_space) using normal likelihood
  • 4. linear model (with predictor living_space) using t-student likelihood

Either 2. or 4. can possibly be omitted.

Visualizations of the model

Need some visualizations of the resulting hierarchical model

Similar as in the R talk, get ~4 example ZIP codes for which to visualize the model

  • "spaghetti" plot
  • full uncertainty plot
  • research the ZIP code of the conference

Further, we need some visualizations for a single prediction:

  • Histogram of the predicted log_sqm_price
  • Histogram of the transformed prediction, that is the full price
  • Mark probability that price < x€ in histogram (or waffle chart or quantile dot plot)

prior predictive checks

Need an example of using prior predictive checks with

  • flat priors
  • weakly informative priors

Preferably two visualizations:

  • the parameter distributions
  • the resulting linear model (spaghetti plot)

Shapefile plots

Visualization of the

  • intercept per ZIP for whole Berlin
  • probability of getting a house <x€ in ZIP code (this might easily be misinterpreted though)
  • research how to visualize uncertainty in maps

For this, need to find a good way of plotting the shapefiles.
Probably geopandas.

Increase Reproducibility

Ideally, all code and notebooks should be reproducible:

  • Docker
  • Pipenv or other Python package management
  • Make file
  • Documentation, how to setup everything

Preferably, most stuff should work pretty much the same with both data sets.

convergency checks

Needed convergency checks:

  • trace plot
  • at least one negative example for trace plots
  • Rhat
  • # effective sample size
  • divergency checks (any divergencies?)

Cherry:

  • simple reporting function similar to shinystan

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.