The HPBNET Procedure
Example 4.6 Model Selection
This example uses Sampsio.Dmagecr, the German Credit sample data, to learn the best Bayesian network model among all network structures: naive, TAN, PC, and MB, with or without variable selection. PROC HPBNET also tries to choose the best value for the MAXPARENTS= option. About 30% of the input data is used for validation.
proc hpbnet data=sampsio.dmagecr numbin=10 alpha=0.05
structure=Naive TAN PC MB varselect=0 1 bestmodel;
target Good_Bad;
input Checking History Purpose Savings Employed Installp Marital Coapp
Resident Property Other Housing Existcr Job Depends Telephon
Foreign/level=NOM;
input Age Amount Duration/level=INT;
partition FRACTION (VALIDATE=0.3);
output network=network fit=fit validinfo=validinfo;
run;
The following statements produce Figure 9, which shows the fit statistics, including the fact that 742 observations are used for training and 258 are used for validation. In the resulting network, there are 15 nodes, 15 links between the nodes, and the number of parameters is 129.
proc print data=fit noobs label;
run;
Figure 9: Model Selection: Fit Statistics
| Number of Observations for Training | Number of Observations for Validation | Number of Observations Ignored | Sum of Frequencies for Training | Sum of Frequencies for Validation | Sum of Frequencies Ignored | Number of Nodes | Number of Links | Average Degree | Maximum Number of Parents in Network | Number of Parameters | Score |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 742 | 258 | 0 | 742 | 258 | 0 | 15 | 15 | 2 | 2 | 129 | -13179.18 |
The following statements produce Figure 10, which shows that PROC HPBNET has learned a PC Bayesian network structure. In the structure, Checking is the parent of Good_Bad, and Good_Bad is the parent of all the other input variables.
proc print data=network noobs label;
var _parentnode_ _childnode_;
where _type_="STRUCTURE";
run;
Figure 10: Model Selection: Best Structure
| Parent Node | Child Node |
|---|---|
| checking | good_bad |
| good_bad | employed |
| good_bad | foreign |
| good_bad | history |
| good_bad | housing |
| good_bad | marital |
| good_bad | other |
| good_bad | property |
| good_bad | purpose |
| good_bad | savings |
| good_bad | telephon |
| foreign | telephon |
| good_bad | age |
| good_bad | amount |
| good_bad | duration |
The following statements produce Figure 11, which shows the validation results for each parameter combination. The PC Bayesian network structure has misclassified 68 observations out of 258 validation observations when MAXPARENTS is greater than or equal to 2 and VARSELECT=0. The TAN structure has 70 misclassification errors. The MB Bayesian network structure has 74 misclassification errors when MAXPARENTS is greater than or equal to 2. The naive Bayesian network has 76 misclassification errors.
proc print data=validinfo noobs label;
var _bestmodel_ _miserrors_ _structure_ _varselect_ _maxparents_;
run;
Figure 11: Model Selection: Validation Information
| Best Model | Misclassification Errors | Input Parameter: Structure | Input Parameter: Variable Selection | Input Parameter: Maximum Number of Parents |
|---|---|---|---|---|
| YES | 68 | PC | 0 | 2 |
| 68 | PC | 0 | 3 | |
| 68 | PC | 0 | 4 | |
| 68 | PC | 0 | 5 | |
| 70 | TAN | 0 | 2 | |
| 74 | MB | 3 | 2 | |
| 74 | MB | 3 | 3 | |
| 74 | MB | 3 | 4 | |
| 74 | MB | 3 | 5 | |
| 74 | PC | 1 | 2 | |
| 74 | PC | 1 | 3 | |
| 74 | PC | 1 | 4 | |
| 74 | PC | 1 | 5 | |
| 76 | PC | 0 | 1 | |
| 76 | NAIVE | 0 | 1 | |
| 76 | NAIVE | 0 | 2 | |
| 76 | NAIVE | 0 | 3 | |
| 76 | NAIVE | 0 | 4 | |
| 76 | NAIVE | 0 | 5 | |
| 85 | MB | 3 | 1 | |
| 85 | PC | 1 | 1 | |
| 85 | NAIVE | 1 | 1 | |
| 85 | NAIVE | 1 | 2 | |
| 85 | NAIVE | 1 | 3 | |
| 85 | NAIVE | 1 | 4 | |
| 85 | NAIVE | 1 | 5 | |
| 91 | TAN | 1 | 2 |