Skip to content

Commit d8de540

Browse files
Update dhfr-parallel-speed-up.R
1 parent 1e15365 commit d8de540

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

dhfr/dhfr-parallel-speed-up.R

+1-18
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,16 @@ stop.time <- proc.time()
3838
run.time <- stop.time - start.time
3939
print(run.time)
4040

41-
# Method 1 - Use doMC
4241

4342

44-
library(doMC)
45-
registerDoMC(2)
46-
start.time <- proc.time()
47-
Model <- train(Y ~ .,
48-
data = TrainingSet, # Build model using training set
49-
method = "svmPoly" # Learning algorithm
50-
)
51-
stop.time <- proc.time()
52-
run.time <- stop.time - start.time
53-
print(run.time)
54-
55-
56-
# Method 2 - Use doParallel
43+
# Use doParallel
5744
# https://topepo.github.io/caret/parallel-processing.html
5845

5946
library(doParallel)
6047

6148
cl <- makePSOCKcluster(5)
6249
registerDoParallel(cl)
6350

64-
## All subsequent models are then run in parallel
6551
start.time <- proc.time()
6652
Model <- train(Y ~ .,
6753
data = TrainingSet, # Build model using training set
@@ -71,7 +57,6 @@ stop.time <- proc.time()
7157
run.time <- stop.time - start.time
7258
print(run.time)
7359

74-
## When you are done:
7560
stopCluster(cl)
7661

7762

@@ -98,7 +83,6 @@ library(doParallel)
9883
cl <- makePSOCKcluster(5)
9984
registerDoParallel(cl)
10085

101-
## All subsequent models are then run in parallel
10286
start.time <- proc.time()
10387
Model <- train(Y ~ .,
10488
data = TrainingSet, # Build model using training set
@@ -109,7 +93,6 @@ stop.time <- proc.time()
10993
run.time <- stop.time - start.time
11094
print(run.time)
11195

112-
## When you are done:
11396
stopCluster(cl)
11497

11598

0 commit comments

Comments
 (0)