Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Let clues depend on each other
When a pressure alarm trips, a cascade follows: the pressure-rate alarm, then the flow alarm, then the regulator alarm. Naive Bayes treats each lit alarm as a separate witness, so one root cause looks like four independent confirmations. A Bayesian network classifier draws arrows between related features as well as from the class. TAN (tree-augmented naive Bayes) allows each feature one extra parent: just enough to capture chains like this, while staying cheap to learn exactly.
Spacecraft and aircraft fault models are naturally graphs: faults cause symptoms, and symptoms trigger other symptoms. Bayesian network classifiers can encode that structure (learned from data or taken from fault trees), give honest probabilities when alarms co-fire, and stay interpretable as a diagram.
- 1. TAN lets each feature depend on the class and…
- 2. On an alarm cascade, naive Bayes tends to be…
- 3. In the demo with copy probability q = 0.5, naive Bayes and TAN…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Counting a cascade correctly
Fault A lights alarm 1 with probability 0.8 and fault B with probability 0.2. Each of alarms 2–4 repeats the previous alarm with probability q = 0.85. All four alarms are lit.
TAN (true model):
- alarm 1 gives a likelihood ratio of 0.8/0.2 = 4;
- given that the previous alarm is lit, the next one is lit with probability 0.85 under both faults, so each copy has ratio 1;
- posterior P(A) = 4/5 = 0.80.
Naive Bayes:
- it sees each copy’s marginal rate: under A, P(lit) = 0.8·0.85 + 0.2·0.15 = 0.71; under B, 0.2·0.85 + 0.8·0.15 = 0.29;
- each copy adds a ratio of 0.71/0.29 = 2.45, so the total is 4 × 2.45³ = 58.7;
- P(A) = 0.983: near-certain from what is really a single clue.
Learning which features to link. TAN measures how strongly two features are related within each class, using the conditional mutual information I(Xᵢ; Xⱼ | C). It then keeps the strongest set of links that forms a tree (a maximum spanning tree).
The steps in plain English:
- Compute I(Xᵢ; Xⱼ | C) for every pair of features from the training data.
- Find the maximum-weight spanning tree over the features (Prim or Kruskal).
- Pick a root and direct all edges away from it, so each feature has at most one feature parent.
- Add the class as a parent of every feature, and estimate each table P(xⱼ | class, parent) with smoothing.
- Classify by summing log-probabilities, as in naive Bayes, but conditioning on each feature’s parent.
- 1. Likelihood ratio of alarm 1 (0.8 vs 0.2)?
- 2. Under TAN, a lit copy after a lit alarm has likelihood ratio…
- 3. TAN chooses feature links by maximising…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.Learning a TAN
Factorisation: P(c, x) = P(c) ∏ⱼ P(xⱼ | c, x_pa(j)), where pa(j) is at most one feature.
Conditional mutual information: I(Xᵢ; Xⱼ | C) = Σ over c, a, b of P(a, b, c) log [P(a, b | c)/(P(a | c)P(b | c))]. It is zero exactly when the two features are independent given the class (in the empirical distribution).
Optimal tree (Friedman, Geiger and Goldszmidt, 1997). Among all TAN structures, the maximum-likelihood one is the maximum spanning tree with edge weights I(Xᵢ; Xⱼ | C). This extends Chow and Liu (1968) to classification. Prim’s algorithm finds it in O(p²) after O(np²) to compute the weights.
Parameters:
- the CPTs P(xⱼ | c, u) are smoothed counts;
- for binary features there are K(1 + 2(p − 1)) entries, about twice naive Bayes’ Kp.
Inference: log P(c | x) = log P(c) + Σⱼ log P(xⱼ | c, x_pa(j)) − const. This is still a simple sum, in O(Kp) time.
Other members of the family:
- k-dependence Bayesian classifiers (KDB) allow k feature parents;
- AODE averages over one-dependence models, each with a different “super-parent”;
- general Bayesian networks use structure learning with scores (BIC, BDeu) or constraint tests (PC algorithm), or expert-built structure such as fault trees.
# pgmpy provides TAN and general Bayesian networks
from pgmpy.estimators import TreeSearch, MaximumLikelihoodEstimator
from pgmpy.models import BayesianNetwork
dag = TreeSearch(df, root_node="x0").estimate(estimator_type="tan", class_node="fault")
model = BayesianNetwork(dag.edges()); model.fit(df, estimator=MaximumLikelihoodEstimator)Use it when features are discrete (or discretised), have known or strong dependencies (cascades, redundant sensors), and you want calibrated, inspectable probabilistic diagnosis. Avoid it with continuous high-dimensional data or very few examples. With very little data, TAN’s extra tables can be too noisy (exercise 2).
- 1. The maximum-likelihood TAN tree is found by…
- 2. TAN generalises which earlier tree method?
- 3. AODE averages over…
Level 3: Advanced
★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.Theory and trade-offs
Why a tree? General Bayesian network structure learning is NP-hard. Restricting each feature to one feature parent makes the optimal structure computable exactly in polynomial time, and inference stays linear.
Likelihood decomposition. For a TAN, the log-likelihood equals Σⱼ I(Xⱼ; X_pa(j) | C) plus terms that do not depend on the tree. Maximising the likelihood is therefore maximising the total conditional MI along the tree’s edges, which is exactly the spanning-tree problem.
Bias versus variance.
- Naive Bayes: Kp probability tables, high bias when features co-vary.
- TAN: about 2Kp tables, each estimated from a subset (class and parent value), so with little data it is noisier.
- In exercise 2, TAN lost to naive Bayes on accuracy with 60 events (20 per class), and won from 300 events up.
Discriminative versus generative scoring. TAN’s tree maximises the joint likelihood, not classification accuracy. Discriminative structure scoring (for example conditional log-likelihood) can help, at extra computational cost.
Continuous features need discretisation, or Gaussian CPDs (conditional linear Gaussians), which make the model a form of QDA or LDA with structured covariance.
Interview questions.
- How does TAN fix naive Bayes’ overconfidence with correlated features? It models P(xⱼ | c, parent), so a feature that just copies its parent contributes almost no extra evidence.
- When would you prefer an expert-built network? When labelled faults are rare but the causal structure is known, for example from FMEA or fault trees. Learn only the CPTs, or even elicit them.
- 1. TAN's log-likelihood depends on the tree through…
- 2. Learning a general Bayesian network structure is…
- 3. With very little data, TAN can lose to naive Bayes because…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Diagnosing faults from cascading alarms
History.
- Chow and Liu (1968) approximated joint distributions with maximum spanning trees on mutual information.
- Pearl (1988) developed Bayesian networks.
- Friedman, Geiger and Goldszmidt (1997) introduced TAN and showed that it often beats both naive Bayes and C4.5.
- Webb, Boughton and Wang (2005) introduced AODE.
- Bayesian networks for diagnosis grew up in NASA and aerospace prognostics. They include fault diagnosis for spacecraft electrical power systems (for example the ADAPT testbed at NASA Ames), and Microsoft’s printer troubleshooter is a classic.
Exercise 1.
- Prim’s algorithm finds the weight-12 tree in the 4-node example.
- On data where x₁ copies x₀ and x₃ copies x₂, TAN’s tree contains both copy edges.
- Its test log loss is 0.589, against 0.632 for naive Bayes.
Exercise 2: cascading alarms. Setup: 20 alarms in 5 cascades of 4, 3 fault modes, 12 repetitions. Each cell shows accuracy / log loss.
| Training events | Naive Bayes | TAN | Softmax regression |
|---|---|---|---|
| 60 | 0.646 / 1.127 | 0.616 / 0.988 | 0.650 / 0.858 |
| 300 | 0.685 / 0.940 | 0.698 / 0.713 | 0.704 / 0.669 |
| 1500 | 0.679 / 0.950 | 0.701 / 0.656 | 0.703 / 0.654 |
- Naive Bayes’ log loss stays near 0.95 however much data it gets. Counting each cascade four times is a structural error, not a sampling one.
- TAN learns the cascades and cuts log loss by a third, matching softmax regression with 1500 events. It is also slightly more accurate than naive Bayes from 300 events on.
- With 60 events, TAN’s conditional tables are too noisy. It is the least accurate there, though still better calibrated than naive Bayes.
- Softmax regression is strong at every size here, because the evidence happens to be additive on the log scale. TAN’s advantages are its interpretable structure and its natural handling of missing alarms.
Bayesian network classifiers in AI, robotics and aerospace
- Fault diagnosis and FDIR: networks built from fault trees and FMEA, with CPTs learned from test data.
- Prognostics: linking degradation indicators and failure modes.
- Sensor validation: detecting which redundant sensor disagrees with its expected dependencies.
- Explainable AI: structure diagrams make the reasoning auditable.
References
- N. Friedman, D. Geiger, M. Goldszmidt (1997). “Bayesian network classifiers.” Machine Learning 29(2–3).
- C. K. Chow, C. N. Liu (1968). “Approximating discrete probability distributions with dependence trees.” IEEE Transactions on Information Theory 14(3).
- J. Pearl (1988). Probabilistic Reasoning in Intelligent Systems. Morgan Kaufmann.
- G. I. Webb, J. R. Boughton, Z. Wang (2005). “Not so naive Bayes: aggregating one-dependence estimators.” Machine Learning 58(1).
- D. Koller, N. Friedman (2009). Probabilistic Graphical Models. MIT Press.