example_models

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package example_models provides factory functions that return fully parameterized, well-known Bayesian networks from the literature. Each function creates the network structure, adds CPDs with real probability values, sets state names, and validates the model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alarm

func Alarm() *models.BayesianNetwork

Alarm returns a simplified Alarm Bayesian network with 5 nodes. This is a compact version of the classic Burglary-Alarm network from Pearl (1988).

Nodes:

Burglary (B): {No, Yes}
Earthquake (E): {No, Yes}
Alarm (A): {No, Yes}
JohnCalls (J): {No, Yes}
MaryCalls (M): {No, Yes}

Edges: B->A, E->A, A->J, A->M

func AlarmFull

func AlarmFull() *models.BayesianNetwork

AlarmFull returns the full ALARM (A Logical Alarm Reduction Mechanism) network with 37 nodes and 46 edges. From Beinlich et al. (1989). Structure only — CPDs too large to hardcode.

func Asia

func Asia() *models.BayesianNetwork

Asia returns the Asia (chest clinic) Bayesian network with 8 nodes. This network was introduced by Lauritzen & Spiegelhalter (1988).

Nodes:

Asia (A): visit to Asia — {No, Yes}
Tub (T): tuberculosis — {No, Yes}
Smoke (S): smoker — {No, Yes}
Lung (L): lung cancer — {No, Yes}
Bronc (B): bronchitis — {No, Yes}
Either (E): tuberculosis or lung cancer — {No, Yes}
Xray (X): positive X-ray — {No, Yes}
Dysp (D): dyspnoea — {No, Yes}

Edges: A->T, S->L, S->B, T->E, L->E, E->X, E->D, B->D

func Barley

func Barley() *models.BayesianNetwork

Barley returns the Barley crop yield network with 48 nodes and 84 edges. From Kristensen & Rasmussen (2002). Structure only — CPDs too large to hardcode.

func Cancer

func Cancer() *models.BayesianNetwork

Cancer returns the simple Cancer diagnosis Bayesian network with 5 nodes.

Nodes:

Pollution (P): {Low, High}
Smoker (S): {No, Yes}
Cancer (C): {No, Yes}
Xray (X): {Negative, Positive}
Dyspnoea (D): {No, Yes}

Edges: P->C, S->C, C->X, C->D

func Child

func Child() *models.BayesianNetwork

Child returns the Child congenital heart disease network with 20 nodes and 25 edges. From Spiegelhalter et al. (1992). Structure only — CPDs too large to hardcode.

func CoinToss

func CoinToss() *models.BayesianNetwork

CoinToss returns a simple 3-node Bayesian network modeling a biased coin toss.

Nodes:

Bias: {Fair, Biased} — whether the coin is biased
FirstToss: {Heads, Tails}
SecondToss: {Heads, Tails}

Edges: Bias->FirstToss, Bias->SecondToss

func DogProblem

func DogProblem() *models.BayesianNetwork

DogProblem returns a textbook Bayesian network about a dog's behavior. From Charniak (1991) "Bayesian Networks without Tears."

Nodes:

BowelProblem: {true, false}
DogOut: {true, false}
FamilyOut: {true, false}
HearBark: {true, false}
LightOn: {true, false}

Edges: BowelProblem->DogOut, FamilyOut->DogOut, FamilyOut->LightOn, DogOut->HearBark

func Earthquake

func Earthquake() *models.BayesianNetwork

Earthquake returns the classic 5-node Earthquake/Burglary/Alarm network. This is an alias for the same model as Alarm() but with node names matching the bnlearn "earthquake" dataset. The structure is identical to the classic Pearl (1988) example.

This function is provided for compatibility with the bnlearn repository naming.

func FraudDetection

func FraudDetection() *models.BayesianNetwork

FraudDetection returns a simple fraud detection Bayesian network with 6 nodes. This is a textbook-style network for credit card fraud detection.

Nodes:

Fraud: {No, Yes}
Age: {Young, Middle, Old}
Sex: {Male, Female}
ForeignPurchase: {No, Yes}
HighAmount: {No, Yes}
Alert: {No, Yes}

Edges: Fraud->ForeignPurchase, Fraud->HighAmount, Age->Fraud, Sex->Fraud,

ForeignPurchase->Alert, HighAmount->Alert

func Get

func Get(name string) (*models.BayesianNetwork, error)

Get returns a BayesianNetwork for the given model name (case-insensitive). Returns an error if the model name is not recognized.

func Hailfinder

func Hailfinder() *models.BayesianNetwork

Hailfinder returns the Hailfinder weather network with 56 nodes and 66 edges. From Abramson et al. (1996). Structure only — CPDs too large to hardcode.

func Hepar2

func Hepar2() *models.BayesianNetwork

Hepar2 returns the HEPAR II liver disease network with 70 nodes and 123 edges. From Onisko et al. (2001). Structure only — CPDs too large to hardcode.

func Insurance

func Insurance() *models.BayesianNetwork

Insurance returns the Insurance evaluation network with 27 nodes and 52 edges. From Binder et al. (1997). Structure only — CPDs too large to hardcode.

func List

func List() []string

List returns the names of all available example models, sorted alphabetically.

func MedicalDiagnosis

func MedicalDiagnosis() *models.BayesianNetwork

MedicalDiagnosis returns a simple medical diagnosis Bayesian network with 8 nodes. A textbook model for reasoning about patient symptoms and diseases.

Nodes:

Smoking: {No, Yes}
Pollution: {Low, High}
LungCancer: {No, Yes}
Bronchitis: {No, Yes}
Fatigue: {No, Yes}
ChestPain: {No, Yes}
Cough: {No, Yes}
ShortnessOfBreath: {No, Yes}

Edges: Smoking->LungCancer, Smoking->Bronchitis, Pollution->LungCancer,

LungCancer->Fatigue, LungCancer->ChestPain, Bronchitis->Cough,
Bronchitis->ShortnessOfBreath, LungCancer->ShortnessOfBreath

func Mildew

func Mildew() *models.BayesianNetwork

Mildew returns the Mildew crop disease network with 35 nodes and 46 edges. From Kjærulff (1992). Structure only — CPDs too large to hardcode.

func MontyHall

func MontyHall() *models.BayesianNetwork

MontyHall returns the Monty Hall problem as a Bayesian network with 3 nodes.

Nodes:

Prize: {Door1, Door2, Door3} — which door hides the prize
Guest: {Door1, Door2, Door3} — which door the guest picks
Host: {Door1, Door2, Door3} — which door the host opens

Edges: Prize->Host, Guest->Host

func Pathfinder

func Pathfinder() *models.BayesianNetwork

Pathfinder returns the Pathfinder lymph-node disease network with 109 nodes and 195 edges. From Heckerman et al. (1992). Structure only — CPDs too large to hardcode.

func Pigs

func Pigs() *models.BayesianNetwork

Pigs returns the Pigs genetic pedigree network with 441 nodes and 592 edges. From Cowell et al. (1999). Structure only — CPDs too large to hardcode.

func Sachs

func Sachs() *models.BayesianNetwork

Sachs returns the Sachs protein signaling Bayesian network with 11 nodes. This network was learned from flow cytometry data by Sachs et al. (2005). Only the structure is provided (no CPDs) since the full parameterization is too large to hardcode.

Nodes: Raf, Mek, Plcg, PIP2, PIP3, Erk, Akt, PKA, PKC, P38, Jnk

Note: CheckModel() will fail on this network because CPDs are not set. Use it for structure-only tasks such as structure learning evaluation.

func Student

func Student() *models.BayesianNetwork

Student returns the classic Student Bayesian network with 5 nodes:

D (Difficulty): 2 states {Easy, Hard}
I (Intelligence): 2 states {Low, High}
G (Grade): 3 states {A, B, C}
L (Letter): 2 states {Weak, Strong}
S (SAT): 2 states {Low, High}

Edges: D->G, I->G, I->S, G->L CPD values from Koller & Friedman (2009).

func Survey

func Survey() *models.BayesianNetwork

Survey returns the Survey Bayesian network with 6 nodes. This network models the relationship between age, sex, education, occupation, residence, and travel mode. CPD values from the bnlearn repository (Scutari, 2010).

Nodes:

A (Age): {young, adult, old}
S (Sex): {M, F}
E (Education): {high, uni}
O (Occupation): {emp, self}
R (Residence): {small, big}
T (Travel): {car, train, other}

Edges: A->E, S->E, E->O, E->R, O->T, R->T

func VisitAsia

func VisitAsia() *models.BayesianNetwork

VisitAsia returns the Asia network under an alternative name for compatibility. Some libraries refer to this model as "VisitAsia" rather than "Asia."

func Water

func Water() *models.BayesianNetwork

Water returns the Water purification network with 32 nodes and 66 edges. From Jensen et al. (1989). Structure only — CPDs too large to hardcode.

func WaterSprinkler

func WaterSprinkler() *models.BayesianNetwork

WaterSprinkler returns the classic Rain/Sprinkler/WetGrass Bayesian network.

Nodes:

Cloudy (C): {No, Yes}
Sprinkler (S): {Off, On}
Rain (R): {No, Yes}
WetGrass (W): {No, Yes}

Edges: Cloudy->Sprinkler, Cloudy->Rain, Sprinkler->WetGrass, Rain->WetGrass

func Win95pts

func Win95pts() *models.BayesianNetwork

Win95pts returns the Win95pts printer troubleshooting network with 76 nodes and 112 edges. From Heckerman et al. (1995). Structure only — CPDs too large to hardcode.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL