The BNET Procedure
PROC BNET Statement
PROC BNET <options>;
The PROC BNET statement invokes the procedure. Table 1 summarizes important options in the PROC BNET statement by function.
Table 1: PROC BNET Statement Options
| Option | Description |
|---|---|
| Data Options | |
| DATA= | Specifies the input data set |
| MISSINGINT= | Specifies how to handle missing values for interval variables |
| MISSINGNOM= | Specifies how to handle missing values for nominal variables |
| NUMBIN= | Specifies the number of binning levels for interval variables |
| PRESCREENING= | Specifies the initial screening for the input variables |
| VARSELECT= | Specifies the selection for the input variables |
| Independence Test Options | |
| ALPHA= | Specifies the significance level for independence tests by using chi-square or G-square statistics |
| INDEPTEST= | Specifies the method to use for independence tests |
| MIALPHA= | Specifies the significance level for independence tests by using mutual information |
| Structure Learning Options | |
| INNETWORK= | Specifies the CAS table that contains the included and excluded arcs that are defined using pairs of parent and child variables |
| MAXPARENTS= | Specifies the maximum number of parents for each node in the network |
| PARENTING= | Specifies the structure learning method |
| STRUCTURE= | Specifies the network structure type |
| Model Selection Options | |
| BESTMODEL | Requests that the best model be selected |
| Network Output Options | |
| OUTNETWORK= | Specifies the output CAS table that contains the final network and the associated probabilities |
You can specify the following options:
- ALPHA=number
-
specifies the significance level for independence tests by using chi-square or G-square statistics. The valid range is 0 to 1, inclusive. If you want to choose the best model among several, you can specify up to five numbers, separated by spaces. If you specify multiple numbers but you do not specify the BESTMODEL option, PROC BNET uses the first number and ignores the remaining numbers.
By default, ALPHA=0.05.
- BESTMODEL
-
selects the best model by using a validation data subset. You can specify the validation data subset by using the PARTITION statement. If you specify this option, you can specify multiple values for the ALPHA=, PRESCREENING=, VARSELECT=, STRUCTURE=, and PARENTING= options. PROC BNET uses the misclassification errors that arise from the validation data to automatically decide the best set of parameter values among these options. If you supply multiple values of these options in the absence of the BESTMODEL option, then only the first value among the multiple values is used.
By default, the final network is produced for only one set of parameters. You must specify the BESTMODEL option to invoke a search for the best network by using all possible combinations of the specified parameters.
Note: If you specify the BESTMODEL option in the PROC BNET statement, then the AUTOTUNE statement is ignored.
- DATA=CAS-libref.data-table
-
names the input data table for PROC BNET to use. CAS-libref.data-table is a two-level name, where
- CAS-libref
refers to a collection of information that is defined in the LIBNAME statement and includes the
caslib, which includes a path to the data, and a session identifier, which defaults to the active session but which can be explicitly defined in the LIBNAME statement. For more information about CAS-libref, see the section Using CAS Sessions and CAS Engine Librefs.- data-table
specifies the name of the input data table.
- INDEPTEST=ALL | CHIGSQUARE | CHISQUARE | GSQUARE | MI
-
specifies the method to use for independence tests. You can specify the following values:
- ALL
uses the chi-square, the G-square statistics, and the normalized mutual information for independence tests. A variable is independent of the target if both the p-values of the chi-square and the G-square statistics are greater than the specified ALPHA= value and the normalized mutual information is less than the value that is specified in MIALPHA= option.
- CHIGSQUARE
uses both the chi-square and the G-square statistics for independence tests. A variable is independent of the target if both the p-values of the chi-square and the G-square statistics are greater than the specified ALPHA= value.
- CHISQUARE
uses the chi-square statistics for independence tests. A variable is independent of the target if the p-value of the statistics is greater than the specified ALPHA= value.
- GSQUARE
uses the G-square statistics for independence tests. A variable is independent of the target if the p-value of the statistics is greater than the specified ALPHA= value.
- MI
uses the normalized mutual information for independence tests. A variable is independent of the target if the normalized mutual information is less than the value that is specified in the MIALPHA= option.
By default, INDEPTEST=CHIGSQUARE.
-
INNETWORK=CAS-libref.data-table
INNET=CAS-libref.data-table names the input CAS data table that contains the arcs defined as parent-child variable pairs to be included in or excluded from the final network. The flag column in this table indicates that the arc is an included arc if the value of flag is 1, and the arc is an excluded arc if the value of flag is 0. CAS-libref.data-table is a two-level name, where CAS-libref refers to the
casliband session identifier, and data-table specifies the name of the output data table. For more information about this two-level name, see the DATA= option and the section Using CAS Sessions and CAS Engine Librefs.- MAXPARENTS=integer
-
specifies the maximum number of parents that are allowed for each node in the network structure. The valid range is 1 to 16, inclusive. If you specify the BESTMODEL option, PROC BNET calculates from 1 to integer and decides the best number of parents.
By default, MAXPARENTS=5.
- MIALPHA=number
-
specifies the threshold for independence tests by using mutual information. The valid range is 0 to 1, inclusive.
By default, MIALPHA=0.05.
- MISSINGINT=IGNORE | IMPUTE
-
specifies how to handle missing values for all interval input variables. This option applies to training data, validation data, testing data, and any data that are used for scoring. You can specify the following values:
- IGNORE
ignores the observations that have missing values in any of the interval variables.
- IMPUTE
replaces the missing values in any interval variable by the mean of the variable.
By default, MISSINGINT=IGNORE.
- MISSINGNOM=IGNORE | IMPUTE | LEVEL
-
specifies how to handle the missing values for all nominal input variables. You can specify the following values:
- IGNORE
ignores the observations that have missing values in any of the nominal variables.
- IMPUTE
replaces the missing values in any nominal variable by the mode of the variable.
- LEVEL
treats the missing values in any nominal variable as a separate level of the variable.
By default, MISSINGNOM=IGNORE.
- NTHREADS=number-of-threads
specifies the number of threads to use. The default is the minimum CPU count of all the nodes.
-
NUMBIN=integer
NBIN=integer -
specifies the number of binning levels for all interval variables. PROC BNET bins each interval variable into integer equal-width levels. The valid range of integer is 2 to 1,024, inclusive.
By default, NUMBIN=5.
-
OUTNETWORK=CAS-libref.data-table
OUTNET=CAS-libref.data-table names the output CAS data table to contain the network structure and the probability distributions. CAS-libref.data-table is a two-level name, where CAS-libref refers to the
casliband session identifier, and data-table specifies the name of the output data table. For more information about this two-level name, see the DATA= option and the section Using CAS Sessions and CAS Engine Librefs.- PARENTING=BESTONE | BESTSET
-
specifies the algorithm for orienting the network structure. You can specify the following values:
- BESTONE
uses a greedy approach to determine the parents of each node; that is, for each node, the best candidate is added as a parent of the node in each iteration.
- BESTSET
determines the best set of variables among possible candidate sets as the parents of each node; that is, instead of adding one variable in an iteration, PROC BNET tests multiple sets of variables together and chooses the best set as the parents of the node.
If you want to choose between the two methods, you can specify both of them and also specify the BESTMODEL option. If you specify both methods but you do not specify the BESTMODEL option, PROC BNET uses the first specified method, and ignores the other.
By default, PARENTING=BESTSET.
- PRESCREENING=0 | 1
-
specifies the initial screening for the input variables. You can specify the following values:
- 0
uses all the input variables.
- 1
uses only the input variables that are dependent on the target.
If you want to choose the best model with or without prescreening, you can specify PRESCREENING=0 1 or PRESCREENING= 1 0 and also specify the BESTMODEL option. If you specify both but you do not specify the BESTMODEL option, PROC BNET uses the first specified value, and ignores the other.
If you specify STRUCTURE=GENERAL, then any setting of the PRESCREENING= option other than 1 is ignored and PRESCREENING=1 is used.
By default, PRESCREENING=1.
- PRINTTARGET
-
generates the "Predicted Probability Variables" table, which displays the target variable and the predicted probability variables, and the "Predicted Target Variable" table, which displays the predicted target variable.
By default, these two tables are not generated.
- STRUCTURE=values
-
specifies the network structure. Together with the MAXPARENTS= option, this option determines which network structure the procedure learns from the training data. You can specify one or more of the following values, separated by spaces:
- GENERAL | GN
learns a general Bayesian network over the target and input variables. PROC BNET learns a general Bayesian network by using a search algorithm that grows partial networks to completion by exploring among possible completions. For the GENERAL network structure, any specification of the PRESCREENING= option is ignored and PRESCREENING=1 is used. In addition, any specification of the VARSELECT= option is ignored and VARSELECT=0 is used. The meaning of VARSELECT= option is explained in the following discussion of this option.
- MB
learns the Markov blanket of the target variable. The Markov blanket includes the parents, the children, and the other parents of the children. After learning the Markov blanket, PROC BNET further determines the parents of the target, the links from the parents to the children, and the links among the children. When you specify STRUCTURE=MB, the procedure learns the Markov blanket regardless of the values of PRESCREENING= and VARSELECT= options.
- NAIVE
assumes a naive Bayesian network structure (that is, the target has a direct link to each input variable). If MAXPARENTS=1, the structure is a naive Bayesian network (NB). If the value of the MAXPARENTS= option is greater than 1, the structure is a Bayesian network-augmented naive Bayesian network (BAN).
- PC
learns the parent-child Bayesian network structure (PC). STRUCTURE=PC differs from STRUCTURE=NAIVE in that some input variables could be learned as the parents of the target variable. In addition, links from the parents to the children and among the children are also possible in the PC structure.
- TAN
learns the tree-augmented naive Bayesian network structure. The TAN structure includes a direct link from the target to each input variable plus a tree structure among the input variables.
If you want to choose the best structure among several structures, you can specify multiple values in any combination, separated by spaces, and also specify the BESTMODEL option. If you specify multiple structures but you do not specify the BESTMODEL option, PROC BNET uses the first value that you specify and ignores the rest.
By default, STRUCTURE=PC.
- VARSELECT=0 | 1 | 2 | 3
-
specifies how input variables are selected beyond the prescreening. You can specify the following values:
- 0
uses all input variables that remain after the initial screening is performed as specified in the PRESCREENING= option.
- 1
tests each input variable for conditional independence of the target variable given any other input variable. This type of selection uses only the variables that are not rendered conditionally independent of the target given any other input variable.
- 2
tests each input variable further for conditional independence of the target variable given any subset of other input variables. This type of selection uses only the variables that are not rendered conditionally independent of the target given any subset of other input variables.
- 3
determines the Markov blanket of the target variable and uses only the variables in the Markov blanket.
By default, VARSELECT=1.
If you specify VARSELECT=1, 2, or 3, PROC BNET automatically tests each input variable for unconditional independence of the target regardless of the value of the PRESCREENING= option. If no variables are left at a particular variable selection level, PROC BNET reverts to the previous level. For example, if you specify VARSELECT=3 and there are no variables in the Markov blanket of the target, PROC BNET uses the variables from the previous level, VARSELECT=2.
If you want to choose the best model among different levels of variable selections, you can specify any combination of values for the VARSELECT= option and also specify the BESTMODEL option. If you specify multiple values for the VARSELECT= option but you do not specify the BESTMODEL option, PROC BNET uses the first specified value and ignores the remaining values.
If you specify STRUCTURE=GENERAL, then any setting of the VARSELECT= option other than 0 is ignored and VARSELECT=0 is used.
The INNETWORK= option enables you to override the selections that are made by the PRESCREENING= and VARSELECT= options. Thus a variable that is selected by independence tests might not be in the network if you have excluded it by using the INNETWORK= option. Similarly, a variable that is deemed independent of the target might get into the network if you have included it by using the INNETWORK= option. Hence the selections that are made using independence tests are not final, and specifications of the INNETWORK= option can override these selections.