Book Image

Bayesian Analysis with Python

Book Image

Bayesian Analysis with Python

Overview of this book

The purpose of this book is to teach the main concepts of Bayesian data analysis. We will learn how to effectively use PyMC3, a Python library for probabilistic programming, to perform Bayesian parameter estimation, to check models and validate them. This book begins presenting the key concepts of the Bayesian framework and the main advantages of this approach from a practical point of view. Moving on, we will explore the power and flexibility of generalized linear models and how to adapt them to a wide array of problems, including regression and classification. We will also look into mixture models and clustering data, and we will finish with advanced topics like non-parametrics models and Gaussian processes. With the help of Python and PyMC3 you will learn to implement, check and expand Bayesian models to solve data analysis problems.
Table of Contents (15 chapters)
Bayesian Analysis with Python
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Exercises


  1. Choose a dataset that you find interesting and use it with the simple linear regression model. Re-run the plots and also compute the Pearson correlation coefficient with the different methods. If you do not have one, try searching online, for example at http://data.worldbank.org/ or http://www.stat.ufl.edu/~winner/datasets.html.

  2. Read and run the following example from PyMC3's documentation https://pymc-devs.github.io/pymc3/notebooks/LKJ.html.

  3. For the unpooled model change the value of the sd of the beta prior; try values of 1 and 100. Explore how the estimated slopes change for each group. Which group is the more affected by this change?

  4. See in the accompanying code the model_t2 (and the data associated with it). Experiment with priors for nu. Like the non-shifted exponential and gamma priors (they are commented in the code). Plot the prior distributions to be sure do you understand them; an easy way to do this is to just comment the likelihood in the model and check the traceplot...