Bayesian Networks
Learn about the Bayesian network in detail.
We'll cover the following...
Bayesian networks are probabilistic models that model knowledge about an uncertain domain, such as the survival of a passenger aboard the Titanic.
Bayesian networks build on the same intuitions as the Naïve Bayes classifier, but in contrast to Naïve Bayes, Bayesian networks are not restricted to represent solely independent features. They allow us to include as many interdependences that appear reasonable in the current setting.
A Bayesian network is represented as a directed acyclic graph with nodes and edges.
The nodes represent random variables, such as the sex of a passenger or whether they were a child.
The edges correspond to the direct influence of one variable on another. In other words, the edges define the relationship between two variables. The directions of the arrows are important, too. The node connected to the tail of the arrow is the parent node. The node connected to the head is the child node. The child node depends on the parent node.
We quantify this dependence using conditional probability tables (CPT) for discrete variables and conditional probability distributions (CPD) for continuous variables.
The following table depicts the posterior probabilities of survival given a passenger’s sex (Sex
).
Probability of survival given a passenger’s sex
Female | Male | |
P(Survival=True | Sex) | 0.74 | 0.19 |
P(Survival=False | Sex) | 0.26 | 0.81 |
Female passengers had a much better chance of surviving than male passengers.
While there are only two sexes in our dataset, there are many different ages of passengers. Technically, being a discrete variable, it seems appropriate to model age as a continuous variable. The following graph depicts the CPD of the posterior probability of survival given a passenger’s Age
.
At first sight, it seems as though a passenger’s age doesn’t have an apparent effect on the chances to survive. Additionally, the chance to survive varies a lot between subsequent ages. For instance, a 47-year old passenger had a chance of survival, whereas a 48-year old had a ...