Bayesian Modeling: PyMC, Stan and Probabilistic Programming Workflows

Episode 4 67 min

Rob Zinkov Machine learning engineer and data scientist

Episode 4 · Bayesian Modeling: PyMC, Stan and Probabilistic Programming Workflows

67 min

What we talked about

Rob Zinkov is a machine learning engineer and data scientist who now works mainly as a statistical consultant. He was a research scientist at Indiana University, where he worked on Hakaru, a probabilistic programming language whose name means "to measure" in Japanese, and he later did a PhD at Oxford on deep Bayesian models such as VAEs. Alexey invites him to explain Bayesian modeling, how it differs from the frequentist approach, and what probabilistic programming adds.

Rob started as a software engineer who scraped web data, cleaned it and put it in databases. He became interested in Bayesian modeling because many problems did not fit tools like scikit-learn or a random forest. He says he never took a formal statistics class and kept buying statistics textbooks until the ideas felt comfortable. He notes that companies often hire software engineers and hope to teach them statistics later.

Using annual rainfall in Germany as the running example, Rob explains that frequentist statistics gives a point estimate with a confidence interval, while Bayesian modeling starts from a prior distribution and uses Bayes' rule to get a posterior. Because it is distribution in, distribution out, the approach is composable, so an analysis can grow step by step. The hard part is that most of the integrals involved have no closed form, so they are approximated by sampling. Markov chain Monte Carlo works because high-probability points tend to be near each other. Probabilistic programming languages take care of these tedious steps, so the user writes the model and gets a sampler. Rob argues that a model with its own ifs and loops that change how probabilities are computed is a language, not just a library.

Rob sketches a short PyMC model with a national mean, city-level rainfall and observed sewer levels, and explains that PyMC builds a computational graph from the Python code. The model can then be checked against government records and refined, extended with spatial structure or distance from the sea, and it can represent multimodal answers such as drought and normal years. He calls Stan the leading probabilistic programming system, which brought Hamiltonian Monte Carlo into popular use and made it work out of the box with the no-U-turn sampler (NUTS).

For students with a frequentist background, Rob recommends Bayesian Modeling and Computation in Python, written by PyMC developers and free online, Bayesian Statistics for Hackers, and Richard McElreath's Statistical Rethinking course and book, whose examples volunteers have ported to PyMC.

Chapters

  1. 1:44 Guest Introduction: Rob Zinkov and the Hakaru probabilistic programming project 1 min
  2. 2:46 Career Journey: From software engineering to machine learning research 1 min
  3. 3:57 Industry vs Academia: Applying Bayesian tools in real problems 3 min
  4. 6:40 Transitioning Skills: Embracing calculus, integrals, and optimization 2 min
  5. 8:12 Core Technical Skills: Linear algebra and optimization for ML 1 min
  6. 9:32 Self-Study Path: Learning statistics without formal classes 5 min
  7. 14:47 Statistical Paradigms: Frequentist point estimates vs Bayesian distributions 4 min
  8. 19:06 Bayesian Workflow: Priors, likelihoods, and posterior distributions 2 min
  9. 21:31 Bayesian Advantages: Composability and incremental model building 2 min
  10. 23:45 Probabilistic Programming: Automating Bayesian model tasks 1 min
  11. 24:29 Why Integrals Matter: Intractable integrals in probabilistic models 2 min
  12. 26:40 Numerical Integration: Sampling as an approximation technique 3 min
  13. 29:17 Samplers Overview: Using draws to estimate posterior expectations 5 min
  14. 33:48 MCMC Fundamentals: Markov chains and exploring high-probability regions 3 min
  15. 36:39 Probabilistic Languages: Hakaru’s role in generating samplers 3 min
  16. 39:38 Language vs Library: Model semantics, control flow, and ASTs 4 min
  17. 43:20 PyMC Example: Building a rainfall model and computational graph 5 min
  18. 48:10 Interpreting Posteriors: Model checks and iterative refinement 3 min
  19. 51:17 Encoding Dependencies: Spatial models and hierarchical structure 2 min
  20. 53:12 Multimodality & Uncertainty: Representing multiple plausible outcomes 2 min
  21. 55:41 Stan & HMC/NUTS: Advances in efficient sampling algorithms 5 min
  22. 1:00:47 Learning Resources: PyMC book, Statistical Rethinking course, and tutorials 5 min
  23. 1:05:53 Consulting & Contact: Rob’s statistical consulting and email 1 min
  24. 1:06:31 Episode Wrap-up, Links, and Next Steps <1 min

About Rob Zinkov

Rob Zinkov Machine learning engineer and data scientist

Rob Zinkov is a machine learning engineer and data scientist specializing in probabilistic programming and Bayesian modeling. His work covers how to efficiently specify and train deep generative models and how to discover good statistical models for your data. Previously, he was a research scientist at Indiana University, where he was the lead developer of the Hakaru probabilistic programming language.

Topics in this episode

The wiki pages this conversation is filed under, the strongest first.

Machine Learning

Machine learning as applied modeling, evaluation, production design, monitoring, roles, and business tradeoffs.

Tools

How data and ML teams choose and sustain tools across data engineering, MLOps, search, RAG, open source, and developer experience.

Related books

Advanced Algorithms and Data Structures

29 questions answered

As a software engineer, you’ll encounter countless programming challenges that initially seem confusing, difficult, or even impossible. Don’t despair! Many of these “new” problems already have well-established solutions. Advanced Algorithms and Data Structures teaches you powerful approaches to a wide range of tricky coding challenges that you can adapt and apply to your own applications. Providing a balanced blend of classic, advanced, and new algorithms, this practical guide upgrades your programming toolbox with new perspectives and hands-on techniques.

Marcello La Rocca

Machine Learning Design Patterns

14 questions answered

The design patterns in this book capture best practices and solutions to recurring problems in machine learning. The authors, three Google engineers, catalog proven methods to help data scientists tackle common problems throughout the ML process. These design patterns codify the experience of hundreds of experts into straightforward, approachable advice.

Valliappa Lakshmanan Sara Robinson Michael Munn

Optional analytics

Optional analytics are off unless you allow them. Your choice does not affect access to DataTalks.Club, Slack, events, or courses.

Current choice: not chosen.

Privacy Policy

If you allow analytics, self-hosted Umami counts anonymous public pageviews without analytics cookies. Private account and learning pages are excluded. Read the Privacy Policy for the complete data boundary.

Want to learn more about our community?

How it started, who's here, and everything that goes on here: courses, events, Slack, and more.

About DataTalks.Club