You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't easily find CPTs for car insurance Bayes net case study #1285
Page 427 of 4th ed states: The conditional distributions in the model are given in the code repository for the book; we provide a version with only discrete variables, for which exact inference can be performed. However, I can't easily find it in the code repo.
there is no car-insurance network in probability.py or probability4e.py (none of the names RiskAversion, Antilock, DrivingSkill, MedicalCost and so on is there), while the book says that the discrete CPTs are 'in the code repository', so the content is missing
adding it means defining the discrete network with its CPTs as a BayesNet, as burglary and sprinkler; the CPTs are needed first (the full decision network has about 27 nodes, decision and utility nodes included)
I'm leaving this open; with a pointer to the CPTs (e.g., in aima-java or aima-data) I can add the discrete version
the network is the "Insurance" Bayesian network (Binder, Koller, Russell and Kanazawa, Adaptive Probabilistic Networks with Hidden Variables, 1997), a car-insurance model of 27 nodes, and the "conditional distributions given in the code repository" of the book are its discrete version, which neither aima-python nor aima-data has
the full CPTs of the discrete version are in the bnlearn Bayesian Network Repository (https://www.bnlearn.com/bnrepository/, the Insurance network as BIF, DSC or NET); it is also the insurance network of the R package bnlearn, and pgmpy reads it in Python (pgmpy.readwrite.BIFReader('insurance.bif').get_model())
BayesNet and BayesNode here have boolean variables only (each CPT gives P(node=True | parents)), while the variables of Insurance have several values (e.g., Age ∈ {Adolescent, Adult, Senior}, MedCost ∈ {Thousand, TenThou, HundredThou, Million}), so enumeration_ask and elimination_ask need a discrete BayesNet with multi-valued variables first
so this takes (1) multi-valued discrete variables in BayesNet and in inference, and (2) the Insurance network, e.g., with a small BIF reader on the file of the repository; I'm leaving this open for that
done on master (fe83281): aima-python has the car-insurance network and what it takes to use it
DiscreteBayesNode and DiscreteBayesNet (probability.py), nodes whose variables have any finite domain (BayesNet was boolean only), with the interface used by inference (node.p(value, event) and variable_values), so enumeration_ask and elimination_ask work on them as they are
insurance(), which loads the Insurance network of 27 variables (Binder, Koller, Russell and Kanazawa 1997) from aima-data/insurance.bif (now in aima-data), i.e., the discrete CPTs of §16 of the 4th edition
exact inference runs on the whole network; the tests cover a small multi-valued network (enumeration, elimination and the values computed by hand agree), read_bif and the Insurance network
thanks for the pointer to p. 427
Activity
dmeoli commentedon Jun 27, 2026
there is no car-insurance network in probability.py or probability4e.py (none of the names RiskAversion, Antilock, DrivingSkill, MedicalCost and so on is there), while the book says that the discrete CPTs are 'in the code repository', so the content is missing
adding it means defining the discrete network with its CPTs as a BayesNet, as burglary and sprinkler; the CPTs are needed first (the full decision network has about 27 nodes, decision and utility nodes included)
I'm leaving this open; with a pointer to the CPTs (e.g., in aima-java or aima-data) I can add the discrete version
dmeoli commentedon Jun 29, 2026
the network is the "Insurance" Bayesian network (Binder, Koller, Russell and Kanazawa, Adaptive Probabilistic Networks with Hidden Variables, 1997), a car-insurance model of 27 nodes, and the "conditional distributions given in the code repository" of the book are its discrete version, which neither aima-python nor aima-data has
the full CPTs of the discrete version are in the bnlearn Bayesian Network Repository (https://www.bnlearn.com/bnrepository/, the Insurance network as BIF, DSC or NET); it is also the insurance network of the R package bnlearn, and pgmpy reads it in Python (
pgmpy.readwrite.BIFReader('insurance.bif').get_model())BayesNet and BayesNode here have boolean variables only (each CPT gives P(node=True | parents)), while the variables of Insurance have several values (e.g., Age ∈ {Adolescent, Adult, Senior}, MedCost ∈ {Thousand, TenThou, HundredThou, Million}), so enumeration_ask and elimination_ask need a discrete BayesNet with multi-valued variables first
so this takes (1) multi-valued discrete variables in BayesNet and in inference, and (2) the Insurance network, e.g., with a small BIF reader on the file of the repository; I'm leaving this open for that
Add multi-valued discrete Bayes nets + BIF loader; ship the Insurance…
dmeoli commentedon Jun 29, 2026
done on master (fe83281): aima-python has the car-insurance network and what it takes to use it
exact inference runs on the whole network; the tests cover a small multi-valued network (enumeration, elimination and the values computed by hand agree), read_bif and the Insurance network
thanks for the pointer to p. 427
probability notebook: add the car-insurance (Insurance) case-study se…