Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
parallel foreach找不到在循环中创建的对象_R_Foreach_Parallel.foreach_Doparallel - Fatal编程技术网

parallel foreach找不到在循环中创建的对象

parallel foreach找不到在循环中创建的对象,r,foreach,parallel.foreach,doparallel,R,Foreach,Parallel.foreach,Doparallel,这是我的第一个问题,所以我希望我做得对 我正在尝试运行一个名为地理回归森林(package SpatialML)的随机森林变体。为了训练模型,我并行地做了一个foreach循环,并使用一个样本替换校准数据 library(SpatialML) library(doParallel) rm(list=ls()) ds <- SpatialML::random.test.data() ds # Parallel settings ncores <- detectCores() - 1

这是我的第一个问题,所以我希望我做得对

我正在尝试运行一个名为地理回归森林(package SpatialML)的随机森林变体。为了训练模型,我并行地做了一个foreach循环,并使用一个样本替换校准数据

library(SpatialML)
library(doParallel)
rm(list=ls())

ds <- SpatialML::random.test.data()
ds
# Parallel settings
ncores <- detectCores() - 1
cl <- makePSOCKcluster(ncores)


y <- names(ds)[1]
x <- paste(names(ds)[c(2,3)], collapse = "+")

f <- as.formula(paste0(y,"~",x));f

clusterEvalQ(cl , expr = c(library(SpatialML)))
clusterExport(cl, list("ds"))
#### Bootstraps #### 
registerDoParallel(cl)
time <- system.time(foreach (i = 1:10) %dopar% {
  # sample with replacement
  trainingREP <- sample.int(nrow(ds), 1*nrow(ds), replace = T)
  # Geographical Regression Forest
  grf.boot <- grf(formula = f, dframe = ds[trainingREP, ],
                  bw = round(nrow(ds)/10, digits = 0), kernel = "adaptive",
                  coords = ds[trainingREP, c(4,5)], ntree = 500, importance = T)
  # Save GRF
  modelFile <- paste("./bootModGRF_",i,".rds",sep="")
  saveRDS( object = grf.boot, file = modelFile)
  
})stopCluster(cl)
库(SpatialML)
图书馆(双平行)
rm(list=ls())

ds我收到错误
对象“B”未找到
。是的,抱歉,我编辑了代码,现在您不应该有该错误我收到错误
对象“B”未找到
。是的,抱歉,我编辑了代码,现在您不应该有该错误