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.
# \dontrun{ 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 = params , data = dtrain , nrounds = 5L , valids = valids , min_data = 1L , learning_rate = 1.0 )#> [LightGBM] [Warning] Auto-choosing row-wise multi-threading, the overhead of testing was 0.001252 seconds. #> You can set `force_row_wise=true` to remove the overhead. #> And if memory is not enough, you can set `force_col_wise=true`. #> [LightGBM] [Info] Total Bins 232 #> [LightGBM] [Info] Number of data points in the train set: 6513, number of used features: 116 #> [LightGBM] [Info] Start training from score 0.482113 #> [LightGBM] [Warning] No further splits with positive gain, best gain: -inf #> [1]: test's l2:6.44165e-17 #> [LightGBM] [Warning] No further splits with positive gain, best gain: -inf #> [2]: test's l2:1.97215e-31 #> [LightGBM] [Warning] No further splits with positive gain, best gain: -inf #> [3]: test's l2:0 #> [LightGBM] [Warning] No further splits with positive gain, best gain: -inf #> [LightGBM] [Warning] Stopped training because there are no more leaves that meet the split requirements #> [4]: test's l2:0 #> [LightGBM] [Warning] No further splits with positive gain, best gain: -inf #> [LightGBM] [Warning] Stopped training because there are no more leaves that meet the split requirements #> [5]: test's l2:0lgb.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) limit (Mb) max used (Mb) #> Ncells 1954348 104.4 3781007 202 NA 2773227 148.2 #> Vcells 3834739 29.3 8388608 64 16384 8388600 64.0