ecpolley / SuperLearner

Current version of the SuperLearner R package
272 stars 72 forks source link

Bug in mcSuperLearner #138

Closed ellenxtan closed 3 years ago

ellenxtan commented 3 years ago

I tried to replicate the code about mcSuperLearner in the tutorial (https://cran.r-project.org/web/packages/SuperLearner/vignettes/Guide-to-SuperLearner.html) but encountered some error.

Below is my code

data(Boston, package = "MASS")
outcome = Boston$medv
# Create a dataframe to contain our explanatory variables.
data = subset(Boston, select = -medv)
set.seed(1)
# Reduce to a dataset of 150 observations to speed up model fitting.
train_obs = sample(nrow(data), 150)
# X is our training sample.
x_train = data[train_obs, ]

# Create a binary outcome variable: towns in which median home value is > 22,000.
outcome_bin = as.numeric(outcome > 22)
y_train = outcome_bin[train_obs]

(num_cores = RhpcBLASctl::get_num_cores())
options(mc.cores = 2)

# Set multicore compatible seed.
set.seed(1, "L'Ecuyer-CMRG")
# Fit the SuperLearner.
(sl = mcSuperLearner(Y = y_train, X = x_train, family = binomial(),
                    SL.library = c("SL.mean", "SL.glmnet", "SL.ranger")))

However, it gives the below error. Error in parallel::mclapply(validRows, FUN = .crossValFUN, Y = Y, dataX = X, : (list) object cannot be coerced to type 'integer' Timing stopped at: 0 0 0.001

Could you please take a look? Thank you so much!

ellenxtan commented 3 years ago

Failed to reproduce the error. Close the issue for now. Thanks