Bayesian Analysis with Python - Third Edition

Book description

Learn the fundamentals of Bayesian modeling using state-of-the-art Python libraries, such as PyMC, ArviZ, Bambi, and more, guided by an experienced Bayesian modeler who contributes to these libraries

Key Features

  • Conduct Bayesian data analysis with step-by-step guidance
  • Gain insight into a modern, practical, and computational approach to Bayesian statistical modeling
  • Enhance your learning with best practices through sample problems and practice exercises
  • Purchase of the print or Kindle book includes a free PDF eBook.

Book Description

The third edition of Bayesian Analysis with Python serves as an introduction to the main concepts of applied Bayesian modeling using PyMC, a state-of-the-art probabilistic programming library, and other libraries that support and facilitate modeling like ArviZ, for exploratory analysis of Bayesian models; Bambi, for flexible and easy hierarchical linear modeling; PreliZ, for prior elicitation; PyMC-BART, for flexible non-parametric regression; and Kulprit, for variable selection.

In this updated edition, a brief and conceptual introduction to probability theory enhances your learning journey by introducing new topics like Bayesian additive regression trees (BART), featuring updated examples. Refined explanations, informed by feedback and experience from previous editions, underscore the book's emphasis on Bayesian statistics. You will explore various models, including hierarchical models, generalized linear models for regression and classification, mixture models, Gaussian processes, and BART, using synthetic and real datasets.

By the end of this book, you will possess a functional understanding of probabilistic modeling, enabling you to design and implement Bayesian models for your data science challenges. You'll be well-prepared to delve into more advanced material or specialized statistical modeling if the need arises.

What you will learn

  • Build probabilistic models using PyMC and Bambi
  • Analyze and interpret probabilistic models with ArviZ
  • Acquire the skills to sanity-check models and modify them if necessary
  • Build better models with prior and posterior predictive checks
  • Learn the advantages and caveats of hierarchical models
  • Compare models and choose between alternative ones
  • Interpret results and apply your knowledge to real-world problems
  • Explore common models from a unified probabilistic perspective
  • Apply the Bayesian framework's flexibility for probabilistic thinking

Who this book is for

If you are a student, data scientist, researcher, or developer looking to get started with Bayesian data analysis and probabilistic programming, this book is for you. The book is introductory, so no previous statistical knowledge is required, although some experience in using Python and scientific libraries like NumPy is expected.

Table of contents

  1. Bayesian Analysis with Python Third Edition
    1. Preface
    2. Chapter 1 Thinking Probabilistically
      1. 1.1 Statistics, models, and this book’s approach
      2. 1.2 Working with data
      3. 1.3 Bayesian modeling
      4. 1.4 A probability primer for Bayesian practitioners
      5. 1.5 Interpreting probabilities
      6. 1.6 Probabilities, uncertainty, and logic
      7. 1.7 Single-parameter inference
      8. 1.8 How to choose priors
      9. 1.9 Communicating a Bayesian analysis
      10. 1.10 Summary
      11. 1.11 Exercises
      12. Join our community Discord space
    3. Chapter 2 Programming Probabilistically
      1. 2.1 Probabilistic programming
      2. 2.2 Summarizing the posterior
      3. 2.3 Posterior-based decisions
      4. 2.4 Gaussians all the way down
      5. 2.5 Posterior predictive checks
      6. 2.6 Robust inferences
      7. 2.7 InferenceData
      8. 2.8 Groups comparison
      9. 2.9 Summary
      10. 2.10 Exercises
      11. Join our community Discord space
    4. Chapter 3 Hierarchical Models
      1. 3.1 Sharing information, sharing priors
      2. 3.2 Hierarchical shifts
      3. 3.3 Water quality
      4. 3.4 Shrinkage
      5. 3.5 Hierarchies all the way up
      6. 3.6 Summary
      7. 3.7 Exercises
      8. Join our community Discord space
    5. Chapter 4 Modeling with Lines
      1. 4.1 Simple linear regression
      2. 4.2 Linear bikes
      3. 4.3 Generalizing the linear model
      4. 4.4 Counting bikes
      5. 4.5 Robust regression
      6. 4.6 Logistic regression
      7. 4.7 Variable variance
      8. 4.8 Hierarchical linear regression
      9. 4.9 Multiple linear regression
      10. 4.10 Summary
      11. 4.11 Exercises
      12. Join our community Discord space
    6. Chapter 5 Comparing Models
      1. 5.1 Posterior predictive checks
      2. 5.2 The balance between simplicity and accuracy
      3. 5.3 Measures of predictive accuracy
      4. 5.4 Calculating predictive accuracy with ArviZ
      5. 5.5 Model averaging
      6. 5.6 Bayes factors
      7. 5.7 Bayes factors and inference
      8. 5.8 Regularizing priors
      9. 5.9 Summary
      10. 5.10 Exercises
      11. Join our community Discord space
    7. Chapter 6 Modeling with Bambi
      1. 6.1 One syntax to rule them all
      2. 6.2 The bikes model, Bambi’s version
      3. 6.3 Polynomial regression
      4. 6.4 Splines
      5. 6.5 Distributional models
      6. 6.6 Categorical predictors
      7. 6.7 Interactions
      8. 6.8 Interpreting models with Bambi
      9. 6.9 Variable selection
      10. 6.10 Summary
      11. 6.11 Exercises
      12. Join our community Discord space
    8. Chapter 7 Mixture Models
      1. 7.1 Understanding mixture models
      2. 7.2 Finite mixture models
      3. 7.3 The non-identifiability of mixture models
      4. 7.4 How to choose K
      5. 7.5 Zero-Inflated and hurdle models
      6. 7.6 Mixture models and clustering
      7. 7.7 Non-finite mixture model
      8. 7.8 Continuous mixtures
      9. 7.9 Summary
      10. 7.10 Exercises
      11. Join our community Discord space
    9. Chapter 8 Gaussian Processes
      1. 8.1 Linear models and non-linear data
      2. 8.2 Modeling functions
      3. 8.3 Multivariate Gaussians and functions
      4. 8.4 Gaussian processes
      5. 8.5 Gaussian process regression
      6. 8.6 Gaussian process regression with PyMC
      7. 8.7 Gaussian process classification
      8. 8.8 Cox processes
      9. 8.9 Regression with spatial autocorrelation
      10. 8.10 Hilbert space GPs
      11. 8.11 Summary
      12. 8.12 Exercises
      13. Join our community Discord space
    10. Chapter 9 Bayesian Additive Regression Trees
      1. 9.1 Decision trees
      2. 9.2 BART models
      3. 9.3 Distributional BART models
      4. 9.4 Constant and linear response
      5. 9.5 Choosing the number of trees
      6. 9.6 Summary
      7. 9.7 Exercises
      8. Join our community Discord space
    11. Chapter 10 Inference Engines
      1. 10.1 Inference engines
      2. 10.2 The grid method
      3. 10.3 Quadratic method
      4. 10.4 Markovian methods
      5. 10.5 Sequential Monte Carlo
      6. 10.6 Diagnosing the samples
      7. 10.7 Convergence
      8. 10.8 Effective Sample Size (ESS)
      9. 10.9 Monte Carlo standard error
      10. 10.10 Divergences
      11. 10.11 Keep calm and keep trying
      12. 10.12 Summary
      13. 10.13 Exercises
      14. Join our community Discord space
    12. Chapter 11 Where to Go Next
      1. Join our community Discord space
    13. Bibliography
    14. Other Books You May Enjoy
    15. Index

Product information

  • Title: Bayesian Analysis with Python - Third Edition
  • Author(s): Osvaldo Martin
  • Release date: January 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781805127161