View source: R/structuralLearning.R
| getStructure | R Documentation |
Learn the structure of a hybrid Bayesian network, using a fixed method (Naive Bayes, NB), a restricted method (Tree augmented Naive Bayes, TAN), or an unrestricted method (the hill climbing, HC, score-based local search method).
getStructure(data, method, target = NULL)
data |
A dataset with discrete and continuous variables. If the discrete
variables are not of class |
method |
A |
target |
An optional parameter only used in the case of NB and TAN to specify the class variable. |
getStructure() automatically converts non-numeric variables into factors
before calling function hc() from the bnlearn package. In the case of TAN, it converts
all numeric and non-numeric variables into factors (using 4 equal width intervals)
before calling tree.bayes() from the bnlearn package.
The output is a "bn" object containing the learned graph.
hc
## Data
data(ecoli)
ecoli <- ecoli[,-1] ## Sequence Name
## DAG1
dag1 <- getStructure(ecoli, method = "HC")
dag1
plot(dag1)
## DAG2
dag2 <- getStructure(ecoli, method = "TAN", target = "mcg")
dag2
plot(dag2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.