Attempts to unload LightGBM packages so you can remove objects cleanly without having to restart R. This is useful for instance if an object becomes stuck for no apparent reason and you do not want to restart R to fix the lost object.
lgb.unloader(restore = TRUE, wipe = FALSE, envir = .GlobalEnv)
restore | Whether to reload |
---|---|
wipe | Whether to wipe all |
envir | The environment to perform wiping on if |
NULL invisibly.
library(lightgbm) data(agaricus.train, package = "lightgbm") train <- agaricus.train dtrain <- lgb.Dataset(train$data, label = train$label) data(agaricus.test, package = "lightgbm") test <- agaricus.test dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label) params <- list(objective = "regression", metric = "l2") valids <- list(test = dtest) model <- lgb.train(params, dtrain, 100, valids, min_data = 1, learning_rate = 1, early_stopping_rounds = 10)#> [1]: test's l2:6.44165e-17 #> [2]: test's l2:6.44165e-17 #> [3]: test's l2:6.44165e-17 #> [4]: test's l2:6.44165e-17 #> [5]: test's l2:6.44165e-17 #> [6]: test's l2:6.44165e-17 #> [7]: test's l2:6.44165e-17 #> [8]: test's l2:6.44165e-17 #> [9]: test's l2:6.44165e-17 #> [10]: test's l2:6.44165e-17 #> [11]: test's l2:6.44165e-17lgb.unloader(restore = FALSE, wipe = FALSE, envir = .GlobalEnv) rm(model, dtrain, dtest) # Not needed if wipe = TRUE gc() # Not needed if wipe = TRUE#> used (Mb) gc trigger (Mb) max used (Mb) #> Ncells 2013902 107.6 3605147 192.6 3605147 192.6 #> Vcells 4874663 37.2 10146329 77.5 10146328 77.5