我正在使用R包bnlearn来估计贝叶斯网络结构。它使用parallel包进行内建并行化。然而,这是行不通的。
使用手册bnlearn::parallel integration中的示例
library(parallel)
library(bnlearn)
cl = makeCluster(2)
# check it works.
clusterEvalQ(cl, runif(10)) # -> this works
data(learning.test)
res = gs(learning.test, cluster = cl)这里我得到了错误"Error in check.cluster(cluster) : cluster is not a valid cluster object."
有人知道怎么做吗?
发布于 2015-02-09 19:04:39
这是个窃听器。请向包维护人员报告。
这是check.cluster的代码
function (cluster)
{
if (is.null(cluster))
return(TRUE)
if (any(class(cluster) %!in% supported.clusters))
stop("cluster is not a valid cluster object.")
if (!requireNamespace("parallel"))
stop("this function requires the parallel package.")
if (!isClusterRunning(cluster))
stop("the cluster is stopped.")
}现在,如果您查看cl类
class(cl)
#[1] "SOCKcluster" "cluster" 让我们重现一下支票:
bnlearn:::supported.clusters
#[1] "MPIcluster" "PVMcluster" "SOCKcluster"
`%!in%` <- function (x, table) {
match(x, table, nomatch = 0L) == 0L
}
any(class(cl) %!in% bnlearn:::supported.clusters)
#[1] TRUEcluster不在supported.clusters。我认为,函数应该只检查集群是否有一个受支持的类,而不是它是否有一个不受支持的类。
作为一项工作,您可以更改supported.clusters:
assignInNamespace("supported.clusters",
c("cluster", "MPIcluster",
"PVMcluster", "SOCKcluster"),
"bnlearn")https://stackoverflow.com/questions/28415654
复制相似问题