[英]parallelization of bnlearn (with parallel package)
我使用R
包bnlearn
來估計貝葉斯網絡結構。 它具有使用parallel
包的內置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."
有人知道怎么做這個嗎?
這是一個錯誤。 請將其報告給軟件包維護者。
這是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] TRUE
cluster
不在supported.clusters
。 我相信,該函數應該只檢查集群是否有受支持的類,而不是它是否具有不受支持的類。
作為解決方案,您可以更改supported.clusters
:
assignInNamespace("supported.clusters",
c("cluster", "MPIcluster",
"PVMcluster", "SOCKcluster"),
"bnlearn")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.