@@ -38,30 +38,16 @@ stop.time <- proc.time()
38
38
run.time <- stop.time - start.time
39
39
print(run.time )
40
40
41
- # Method 1 - Use doMC
42
41
43
42
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
57
44
# https://topepo.github.io/caret/parallel-processing.html
58
45
59
46
library(doParallel )
60
47
61
48
cl <- makePSOCKcluster(5 )
62
49
registerDoParallel(cl )
63
50
64
- # # All subsequent models are then run in parallel
65
51
start.time <- proc.time()
66
52
Model <- train(Y ~ . ,
67
53
data = TrainingSet , # Build model using training set
@@ -71,7 +57,6 @@ stop.time <- proc.time()
71
57
run.time <- stop.time - start.time
72
58
print(run.time )
73
59
74
- # # When you are done:
75
60
stopCluster(cl )
76
61
77
62
@@ -98,7 +83,6 @@ library(doParallel)
98
83
cl <- makePSOCKcluster(5 )
99
84
registerDoParallel(cl )
100
85
101
- # # All subsequent models are then run in parallel
102
86
start.time <- proc.time()
103
87
Model <- train(Y ~ . ,
104
88
data = TrainingSet , # Build model using training set
@@ -109,7 +93,6 @@ stop.time <- proc.time()
109
93
run.time <- stop.time - start.time
110
94
print(run.time )
111
95
112
- # # When you are done:
113
96
stopCluster(cl )
114
97
115
98
0 commit comments