mirror of
https://github.com/andre-wojtowicz/r-distributed-computing
synced 2024-11-03 14:10:28 +01:00
42 lines
879 B
R
42 lines
879 B
R
# ---- init ----
|
|
|
|
source("init.R")
|
|
|
|
setup.logger(file.path(LOGGER.OUTPUT.DIR, LOGGER.OUTPUT.TEST.FILE),
|
|
LOGGER.OVERWRITE.EXISTING.FILES)
|
|
|
|
source("init-parallel.R")
|
|
|
|
# ---- foreach-test ----
|
|
|
|
flog.info("Test foreach")
|
|
|
|
fdata = foreach::foreach(i = 1:foreach::getDoParWorkers(),
|
|
.combine = c) %dopar%
|
|
{
|
|
Sys.sleep(1)
|
|
return(i)
|
|
}
|
|
|
|
print(fdata)
|
|
|
|
# ---- caret-test ----
|
|
|
|
flog.info("Test caret")
|
|
|
|
tr.control = caret::trainControl(method = "repeatedcv",
|
|
number = 10,
|
|
repeats = 10,
|
|
allowParallel = TRUE)
|
|
|
|
model = caret::train(form = mpg ~ .,
|
|
data = mtcars,
|
|
method = "svmLinear",
|
|
trControl = tr.control)
|
|
|
|
print(model)
|
|
|
|
# ---- shutdown ----
|
|
|
|
stop.cluster()
|