Biology Reference
In-Depth Information
> parSapply(hailfinder, cl = cl, FUN = nlevels)
> most.common = function(x) {
+ names(which.max(table(x)))
+ }#MOST.COMMON
> parSapply(cl, hailfinder, most.common)
(b) > folds = split(sample(nrow(hailfinder)),
+ seq_len(length(cl)))
> small.counts = function(x, data) {
+
sapply(data[x, ],function(y) any(table(y) <= 5))
+}
> parSapply(cl, folds, small.counts,
+ data = hailfinder)
(c) > h = function(x){
+ p = prop.table(table(x))
+ return(sum(-p * log(p)))
> }#H
> parSapply(cl, hailfinder, h)
> stopCluster(cl)
5.2 Consider the alarm data set included in bnlearn.
(a) Learn the structure of the network using Inter-IAMB and a shrinkage test
with alpha = 0.01 , and measure the execution time of the algorithm.
(b) Does a 2-node cluster provide a greater performance improvement than
just switching from optimized = FALSE to optimized = TRUE ?
(c) Is that still true when a Monte Carlo permutation test is used?
(a) > library(snow)
> cl = makeCluster(2, type = "SOCK")
> clusterSetupSPRNG(cl)
> system.time(inter.iamb(alarm, test = "mi-sh",
+ alpha = 0.01))
(b) > system.time(inter.iamb(alarm, test = "mi-sh",
+ alpha = 0.01, optimized = FALSE))
> system.time(inter.iamb(alarm, test = "mi-sh",
+ alpha = 0.01, cluster = cl))
The nonparallelized, optimized algorithm is about twice as fast as the non-
optimized one. It is also faster than using a 2-node cluster by about 30 %.
(c) > system.time(inter.iamb(alarm, test = "mc-mi",
+ alpha = 0.01, B = 1000))
> system.time(inter.iamb(alarm, test = "mc-mi",
+ alpha = 0.01, B = 1000, optimized = FALSE))
> system.time(inter.iamb(alarm, test = "mc-mi",
+ alpha = 0.01, B = 1000, cluster = cl))
> stopCluster(cl)
Search WWH ::




Custom Search