Member-only story

Machine Learning

BBN: Bayesian Belief Networks — How to Build Them Effectively in Python

A detailed explanation of Bayesian Belief Networks using real-life data to build a model in Python

Saul Dobilas
Towards Data Science
10 min readApr 6, 2021

Image by Gerd Altmann from Pixabay

Intro

Most of you may already be familiar with the Naive Bayes algorithm, a fast and simple modeling technique used in classification problems. While it is used widely due to its speed and relatively good performance, Naive Bayes is built on the assumption that all variables (model features) are independent, which in reality is often not true.

In some cases, you may want to build a model where you can specify which variables are dependent, independent, or conditionally independent (this is explained in the next section). You may also want to track real-time how event probabilities change as new evidence is introduced to the model.

This is where the Bayesian Belief Networks come in handy as they allow you to construct a model with nodes and directed edges by clearly outlining the relationships between variables.

Contents

  • The category of algorithms Bayesian Belief Networks (BBN) belong to
  • Introduction to Bayesian Belief Networks (BBN) and Directed…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Towards Data Science

Published in Towards Data Science

Your home for data science and AI. The world’s leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.

Saul Dobilas

Written by Saul Dobilas

Demystifying Data Science and Machine Learning | Let’s connect on LinkedIn 🤝 https://bit.ly/SaulD | Join me on Medium 🤓 https://bit.ly/SolClover

Responses (19)

What are your thoughts?

Thank you for a fantastic article, for a newbie like me. The level of detail and explanation, while not too simplistic, but complete in itself is much appreciated. For example " You can run the same evidence code one more time to remove the evidence…

7

Thanks for the article.
I still struggle to understand one point. The evidence is your training data, right? if yes, shouldnt they contain a format that shows the raining occurance for a given set of measurements on humidity and wind? thanks

1

Hello, this might be a late addition, but it seems that the alternative probs function provided by Andy should not normalize value frequencies during each iteration of the value count, i.e. the indentation of prob = [i/sum(prob) for i in prob] should be on the same level as the first for loop for each if clause.

1