Skip to content

Commit

Permalink
Fixes for reproducibility plus bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
topepo committed Feb 20, 2017
1 parent 7c3ae59 commit df7f787
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,5 @@ bookdown/sa/*


bookdown/make_files.Rout

RegressionTests/package_archives/sdwd_1.0.2.tgz
9 changes: 7 additions & 2 deletions models/files/parRF.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ modelInfo <- list(label = "Parallel Random Forest",
fit = function(x, y, wts, param, lev, last, classProbs, ...) {
workers <- getDoParWorkers()
theDots <- list(...)
theDots$ntree <- if(is.null(theDots$ntree)) 250 else theDots$ntree
theDots$ntree <- if(is.null(theDots$ntree))
formals(randomForest:::randomForest.default)$ntree else
theDots$ntree

theDots$x <- x
theDots$y <- y
theDots$mtry <- param$mtry
theDots$ntree <- ceiling(theDots$ntree/workers)

iter_seeds <- sample.int(10000, size = workers)
out <- foreach(ntree = 1:workers, .combine = combine) %dopar% {
set.seed(iter_seeds[workers])
library(randomForest)
do.call("randomForest", theDots)
}
if(!inherits(out, "randomForest"))
out <- do.call("combine", out)
out$call["x"] <- "x"
out$call["y"] <- "y"
out
Expand Down

0 comments on commit df7f787

Please sign in to comment.