Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco De Lucia
RedModRphree
Commits
6508ec1b
Commit
6508ec1b
authored
Aug 27, 2018
by
Marco De Lucia
Browse files
changed parallelization backend to fix bug in demo-eq-surr-RF.R
parent
391471d5
Changes
1
Show whitespace changes
Inline
Side-by-side
demo/demo-eq-surr-RF.R
View file @
6508ec1b
...
...
@@ -83,6 +83,12 @@ baleq <- list(Calcite=c(C=1, Ca=1), Dolomite=c(C=2, Ca=1, Mg=1))
balance
<-
CheckBalance
(
baleq
,
sam
$
design
,
sam
$
result
)
## we import the caret library
library
(
caret
)
## we register the parallelization backend
doParallel
::
registerDoParallel
(
4
)
set.seed
(
95014
)
fitControl
<-
trainControl
(
method
=
"none"
,
allowParallel
=
TRUE
,
...
...
@@ -92,14 +98,24 @@ fitControl <- trainControl(method = "none",
predictionBounds
=
rep
(
TRUE
,
2
))
## this takes around 8 minutes using 4 cores
## modk <- parallel::mclapply(colnames(sam$result), function (x)
## return(train(x=sam$design, y=sam$result[,x],trControl = fitControl, ##tuneGrid = tg,
## method="parRF")), mc.cores=8)
traintime
<-
system.time
({
mods
<-
parallel
::
mclapply
(
colnames
(
sam
$
result
),
function
(
x
)
return
(
train
(
x
=
sam
$
design
,
y
=
sam
$
result
[,
x
],
trControl
=
fitControl
,
method
=
"parRF"
)),
mc.cores
=
7
)
names
(
mods
)
<-
colnames
(
sam
$
result
)
mods
<-
foreach
(
i
=
colnames
(
sam
$
result
))
%dopar%
caret
::
train
(
x
=
sam
$
design
,
y
=
sam
$
result
[,
i
],
trControl
=
fitControl
,
method
=
"parRF"
)
})
names
(
mods
)
<-
colnames
(
sam
$
result
)
## ## this takes around 8 minutes using 4 cores
## traintime <- system.time({
## mods <- parallel::mclapply(colnames(sam$result), function (x)
## return(train(x=sam$design, y=sam$result[,x],trControl = fitControl,
## method="parRF")), mc.cores=7)
## names(mods) <- colnames(sam$result)
## })
PlotModsInSample
(
mods
,
sam
$
result
,
sam
$
design
)
saveRDS
(
mods
,
"models_equilibrium_RF.rds"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment