O'Reilly logo
live online training icon Live Online training

Probabilistic machine learning in finance

Quantifying uncertainty using PyMC3

Topic: Business
Deepak Kanungo

Unlike many popular machine learning models, such as neural networks, probabilistic models aren’t black boxes. These models enable you to infer causes from effects in a fairly transparent manner. This is important in heavily regulated industries, such as finance and healthcare, where you have to explain the basis of your decisions. The conventional use of maximum likelihood estimates (MLE) in models can lead to costly assessments of risks, so it’s imperative that all models quantify the uncertainty inherent in their point estimates. PyMC3, one of the most popular open source probabilistic programming libraries, makes this process easy.

Join expert Deepak Kanungo to learn how to use PyMC3 to build and fit complex probabilistic models using a few simple lines of Python code. You’ll discover how to quantify the uncertainty inherent in all point estimates, enabling sound business decisions to be made in the face of uncertainty.

What you'll learn-and how you can apply it

By the end of this live online course, you’ll understand:

  • The hazards of using conventional statistics to quantify uncertainty in estimates
  • The benefits of quantifying uncertainty using Bayesian inference
  • The advantages of using PyMC3 to learn from small datasets
  • The concepts behind Bayesian linear regression
  • The underlying principles of change point test analysis of business processes
  • State-of-the-art algorithms like Markov chain Monte Carlo (MCMC), no U-turn sampler (NUTS), and automatic differential variational inference (ADVI) at a high level

And you’ll be able to:

  • Use the PyMC3 library to analyze, design, and develop probabilistic models
  • Explicitly encode personal and institutional knowledge into models
  • Quantify the uncertainty in your company’s cost of capital
  • Estimate the uncertainty around change point tests in business processes
  • Continually update estimates and forecasts based on new data

This training course is for you because...

  • You’re a manager, financial analyst, or developer who needs to build probabilistic models that quantify the uncertainty in your estimates or forecasts.


Recommended preparation:

Recommended follow-up:

About your instructor

  • Deepak Kanungo is the founder and CEO of Hedged Capital LLC, an AI-powered trading and advisory firm that uses probabilistic models and technologies. In 2005, Deepak invented a project portfolio management system using Bayesian inference, the foundation of all probabilistic programming languages. Previously, Deepak was a financial advisor at Morgan Stanley, a Silicon Valley fintech entrepreneur, and a director in the Global Planning Department at Mastercard International. He was educated at Princeton University (astrophysics) and the London School of Economics (finance and information systems).


The timeframes are only estimates and may vary according to how the class is progressing

Overview of probability and Bayesian learning (55 minutes)

  • Group discussion: What’s your experience with statistics and Python?
  • Hands-on exercise: Run the simulation of the Monty Hall problem and discuss its results
  • Presentation: Epistemic probability; how it differs from the frequentist view of probability on which much of conventional statistics is based; Bayes’s theorem, the fundamental algorithm of all probabilistic programming languages; its solution to the Monty Hall problem
  • Q&A

Break (5 minutes)

Using PyMC3 probabilistic programming library (55 minutes)

  • Presentation: Python concepts and declarative commands used for building probabilistic models in PyMC3
  • Hands-on exercise: Walk through the change-point test analysis model in the Colab notebook and analyze its output graphs
  • Q&A

Break (5 minutes)

Errors in financial models and confidence intervals (55 minutes)

  • Hands-on exercise: Work with a market model (MM) that uses standard linear regression with various start and end dates to draw 10 random samples to compute alpha, beta, and sample error of your company’s stock (or a proxy stock if private), including the 95% confidence intervals for all parameters of your company’s cost of capital
  • Presentation: Sources of errors in financial models; the need to quantify uncertainty in point estimates; issues with confidence intervals; the need to use credible intervals instead
  • Q&A

Break (5 minutes)

Quantifying uncertainty using Bayesian linear regression (50 minutes)

  • Presentation: Basic concepts behind the MCMC, NUTS, and ADVI algorithms; what problems they’re best suited to address
  • Hands-on exercise: Recode the MM model in PyMC3 using Bayesian linear regression to produce credible intervals for your company’s cost of capital and all other relevant parameters

Wrap-up and Q&A (10 minutes)