BN object according to a BNDataset.
learn.structure(bn, dataset, algo = "mmhc", scoring.func = "BDeu", initial.network = NULL, alpha = 0.05, ess = 1, bootstrap = FALSE, layering = c(), max.fanin.layers = NULL, max.fanin = num.variables(dataset), layer.struct = NULL, cont.nodes = c(), use.imputed.data = FALSE, use.cpc = TRUE, ...)
"learn.structure"(bn, dataset, algo = "mmhc", scoring.func = "BDeu", initial.network = NULL, alpha = 0.05, ess = 1, bootstrap = FALSE, layering = c(), max.fanin.layers = NULL, max.fanin = num.variables(dataset), layer.struct = NULL, cont.nodes = c(), use.imputed.data = FALSE, use.cpc = TRUE, ...)BN object.BNDataset.sm (Silander-Myllymaki), mmhc
(Max-Min Hill Climbing, default) and sem (Structural Expectation Maximization).BDeu, AIC, BIC.BN object, a matrix containing the adjacency matrix of the structure of the network,
or the string random.chain to sample a random chain as starting point.mmhc).TRUE to use bootstrap samples.sm).sm).sm).mmhc).TRUE to learn the structure from the imputed dataset
(if available, a check is performed). Default is to use raw datasetmmhc) compute Candidate Parent-and-Children sets instead of
starting the Hill Climbing from an empty graph.BN object with DAG.
algo parameter.
The first is the Silander-Myllym\"aki (sm)
exact search-and-score algorithm, that performs a complete evaluation of the search space in order to discover
the best network; this algorithm may take a very long time, and can be inapplicable when discovering networks
with more than 25--30 nodes. Even for small networks, users are strongly encouraged to provide
meaningful parameters such as the layering of the nodes, or the maximum number of parents -- refer to the
documentation in package manual for more details on the method parameters.The second algorithm (and the default one) is the Max-Min Hill-Climbing heuristic (mmhc), that performs a statistical
sieving of the search space followed by a greedy evaluation. It is considerably faster than the complete method, at the cost of a (likely)
lower quality. Also note that in the case of a very dense network and lots of obsevations, the statistical evaluation
of the search space may take a long time. Also for this algorithm there are parameters that may need to be tuned,
mainly the confidence threshold of the statistical pruning.
The third method is the Structural Expectation-Maximization (sem) algorithm,
for learning a network from a dataset with missing values. It iterates a sequence of Expectation-Maximization (in order to ``fill in''
the holes in the dataset) and structure learning from the guessed dataset, until convergence. The structure learning used inside SEM,
due to computational reasons, is MMHC. Convergence of SEM can be controlled with the parameters struct.threshold
and param.threshold, for the structure and the parameter convergence, respectively.
Search-and-score methods also need a scoring function to compute an estimated measure of each configuration of nodes.
We provide three of the most popular scoring functions, BDeu (Bayesian-Dirichlet equivalent uniform, default),
AIC (Akaike Information Criterion) and BIC (Bayesian Information Criterion). The scoring function
can be chosen using the scoring.func parameter.
## Not run:
# dataset <- BNDataset("file.header", "file.data")
# bn <- BN(dataset)
# # use MMHC
# bn <- learn.structure(bn, dataset, alpha=0.05, ess=1, bootstrap=FALSE)
#
# # now use Silander-Myllymaki
# layers <- layering(bn)
# mfl <- as.matrix(read.table(header=F,
# text='0 1 1 1 1 0 1 1 1 1 0 0 8 7 7 0 0 0 14 6 0 0 0 0 19'))
# bn <- learn.structure(bn, dataset, algo='sm', max.fanin=3, cont.nodes=c(),
# layering=layers, max.fanin.layers=mfl, use.imputed.data=FALSE)
# ## End(Not run)
Run the code above in your browser using DataLab