2016-11-11 5 views
0

아래 코드에서 서로 다른 코어에 동시에 두 개의 서로 다른 auto.arima 모델을 병렬로 학습하려고합니다. 코드를 실행하려고하면 아래 오류가 발생합니다. 내 문제가 do.call 또는 parLapply와 관련이 있는지 잘 모르겠다. 또한 병렬 처리가 새로 도입되어 팁이 매우 유용하다.여러 개의 Auto.Arima 모델을 병렬로 학습하십시오.

Code: 
library("forecast") 
library("parallel") 

TList2<-list(x=tsd1, lambda = Tlambda, stepwise=TRUE, approximation = TRUE) 
DList2<-list(x=tsd2, lambda = Rlambda, stepwise=TRUE, approximation = TRUE) 

##Parallelizing ARIMA Model Training 

# Calculate the number of cores 
no_cores <- 1 

# Initiate cluster 
cl <- makeCluster(no_cores) 

ARIMA_List<-list(TList2,DList2) 

ARIMA_Models<-parLapply(cl, ARIMA_List, 
        function(x){do.call(auto.arima, args=x)}) 

stopCluster(cl) 


Error: 
Error in checkForRemoteErrors(val) : 
    one node produced an error: object 'auto.arima' not found 

Data: 

dput(TList2) 
structure(list(x = c(6, 15.5, 22, 16, NA, NA, 13, 13.5, 10, 6, 
14.5, 16, NA, 8, 11, NA, 2, 2, 10, NA, 9, NA, 11, 16, NA, 4, 
17, 7, 11.5, 22, 20.5, 10, 22, NA, 13, 17, 22, 9, 13, 19, 8, 
16, 18, 22, 21, 14, 7, 20, 21.5, 17), lambda = 0.999958829041611, 
    stepwise = TRUE, approximation = TRUE), .Names = c("x", "lambda", 
"stepwise", "approximation")) 

dput(DList2) 
structure(list(x = c(11, 4, 8, 11, 11, NA, 3, 2.5, 6, 11, 7, 
1, NA, 6, 6, NA, 6, 11, 3, NA, 11, NA, 10, 10, NA, NA, 9, 3, 
3, 11, 8, 10, NA, NA, 11, 10, 9, 3, 7, NA, 2, 4, 11, 2.5, 3, 
NA, 4, 7, 1, 5), lambda = 0.170065851742339, stepwise = TRUE, 
    approximation = TRUE), .Names = c("x", "lambda", "stepwise", 
"approximation")) 

답변

0

나는 forecast::auto.arima도 클러스터에서 사용할 수 있으므로이 같은 clusterEvalQ 등을 사용하여 시도해야한다고 생각 :

TList2 <- structure(list(x = c(6, 15.5, 22, 16, NA, NA, 13, 13.5, 10, 6, 
14.5, 16, NA, 8, 11, NA, 2, 2, 10, NA, 9, NA, 11, 16, NA, 4, 
17, 7, 11.5, 22, 20.5, 10, 22, NA, 13, 17, 22, 9, 13, 19, 8, 
16, 18, 22, 21, 14, 7, 20, 21.5, 17), lambda = 0.999958829041611, 
    stepwise = TRUE, approximation = TRUE), .Names = c("x", "lambda", 
"stepwise", "approximation")) 

DList2<- structure(list(x = c(11, 4, 8, 11, 11, NA, 3, 2.5, 6, 11, 7, 
1, NA, 6, 6, NA, 6, 11, 3, NA, 11, NA, 10, 10, NA, NA, 9, 3, 
3, 11, 8, 10, NA, NA, 11, 10, 9, 3, 7, NA, 2, 4, 11, 2.5, 3, 
NA, 4, 7, 1, 5), lambda = 0.170065851742339, stepwise = TRUE, 
    approximation = TRUE), .Names = c("x", "lambda", "stepwise", 
"approximation")) 

library("forecast") 
library("parallel") 
cl <- makeCluster(no_cores) 
clusterEvalQ(cl, library(forecast)) 
ARIMA_List<-list(TList2,DList2) 
ARIMA_Models<-parLapply(cl, ARIMA_List, 
        function(x){do.call(auto.arima, args=x)}) 
stopCluster(cl) 
+0

가 속임수를 썼는지 그, 감사합니다! 나는 병렬 처리가 새로 생겼다. 두 개의 다른 코어에서 동시에 두 모델을 교육하는 코드가 있는가? 또한 clusterEvalQ (cl, library (forecast))를 추가하면 어떻게됩니까? – user6183069

+0

필자는 병렬 컴퓨팅에도 다소 새로운 점이 있습니다. 그리고 나는 당신의 복제본 인 [this] (http://stackoverflow.com/questions/18357788/parallel-parlapply-setup) 게시물에 북마크했습니다. 직관적으로 말하자면, 만약 당신이 단지 1 개의 코어를 사용한다면, 그것은 차이를 만들지 않는다고 말할 수 있습니다. 그러나 더 많이 등록하면 기대 한대로 행동해야합니다 - 아리마를 평행하게 실행하십시오. – lukeA