Lab: Uncertainty
Before the lab
- Reading:
- AIMA: Sections 12.4–12.6 and 13.1–13.3. Focus on conditional independence, Naive Bayes, Bayesian-network semantics, evidence flow, and exact inference by variable elimination. Additionally, skim Section 21.2 for the final notebook segment on estimating probability tables from data.
- Technical preparation:
- Open today's notebook and run all setup cells and the first code cell in Segment 1 to verify that the notebook works in your environment. The output should display the posterior probability distribution over Flu and No flu after observing both fever and cough.
Entry quiz
- 08:30 –
MS Forms
- 10:00 –
MS Forms
Q&A
- Can more evidence make a model less reliable?
- Why can confirming one cause make another cause less likely?
- Why does variable elimination order matter if the posterior remains the same?
- Can a correctly fitted Bayesian network still give misleading probabilities?
Notebook
Notebook: HCAI_Lab_Uncertainty.ipynb (Work in Google Colab or download the .ipynb file to local environment)
Work in groups of 2-4. Every group member must be able to explain the results.
Challenge
Work in groups of 2-4 using the standard ALARM Bayesian network and the official pgmpy parameter-learning workflow.
The network represents dependencies between variables used in patient monitoring. Instead of building a Bayesian network from scratch, you will load an existing benchmark model, investigate its behavior, generate observations, and determine how limited or biased data affect probabilistic inference.
Begin with the official pgmpy example: Parameter Learning in Discrete Bayesian Networks
Use the benchmark model as in the example:
from pgmpy.example_models import load_model alarm_model = load_model("bnlearn/alarm")
Your investigation:
Choose one meaningful query variable and a small set of related evidence variables. Then:
- inspect the relevant part of the network;
- define at least four evidence scenarios;
- predict the direction of each posterior change before running inference;
- compare at least two variable-elimination orders;
- generate datasets of different sizes from the reference model;
- learn CPDs using maximum-likelihood and Bayesian estimation;
- compare the learned posteriors with the reference model;
- introduce one controlled data problem, such as selection bias or an underrepresented parent configuration;
- explain one limitation of your conclusions.
Start the challenge during the lab and continue it as part of the self-study regarding classes. Selected groups may share their findings at the beginning of the next lab, and particularly insightful analyses may receive bonus points.
Learn more!
- Seeing Theory: Bayesian Inference – interactive visualizations of Bayes’ theorem, likelihood, and prior-to-posterior updating
- pgmpy Example Notebooks – examples extending the laboratory toward structure learning, approximate inference, simulation, dynamic Bayesian networks, junction trees, and causal inference.
- Bayesian Network Repository – standard benchmark networks of different sizes and domains, including ASIA, ALARM, CHILD, INSURANCE, HAILFINDER, and PATHFINDER.
- Bayes Server Online – an interactive environment for exploring Bayesian networks and observing how evidence changes probability distributions.