aldro61 / mmit

Regression trees for interval censored output data
https://aldro61.github.io/mmit/
GNU General Public License v3.0
7 stars 7 forks source link

do not register parallel backends in your package! #32

Closed tdhock closed 5 years ago

tdhock commented 5 years ago

hi @parismita @aldro61 I noticed you register a parallel backend in your R code https://github.com/aldro61/mmit/blob/master/Rpackage/R/mmif.cv.R#L73

The whole point of the foreach package is that package developers should be able to use foreach and without having to specify HOW the loop is evaluated (in parallel on your machine, in parallel on a cluster, or sequential on your machine). The users of your package should be able to specify the backend that they want to use in their R scripts.

Actually I would recommend replacing the foreach loop here https://github.com/aldro61/mmit/blob/master/Rpackage/R/mmif.cv.R#L76 with future.apply::future_lapply which is more configurable. https://cran.r-project.org/web/packages/future.apply/index.html

parismita commented 5 years ago

ok...will do that

parismita commented 5 years ago

@tdhock how do I get the current index for future_lapply?

x = 1:nrow(parameters) fitscore_result <- future_lapply(x, FUN = fit_and_score(target.mat = target.mat, feature.mat = feature.mat, parameters = parameters[????,], n_folds = n_folds, scorer = scorer, pruning = pruning, learner = "mmit"))

I need the current index of lapply to select which prameter to pass. Shall I use future_mapply for that or is there some way to get it in future_lapply?

tdhock commented 5 years ago

the usage is the same as the standard lapply function