Description Usage Arguments Value Examples
View source: R/Laurae.lgb.dmat.R
Geneartes a (list of) lgb.Dataset. Unsupported for clusters. Requires Matrix
and lightgbm
packages.
1 2 |
data |
Type: matrix or dgCMatrix or data.frame or data.table or filename, or potentially a list of any of them. When a list is provided, it generates the appropriate |
label |
Type: numeric, or a list of numeric. The label of associated rows in |
missing |
Type: numeric. The value used to represent missing values in |
save_names |
Type: character or NULL, or a list of characters. If names are provided, the generated |
save_keep |
Type: logical, or a list of logicals. When names are provided, |
clean_mem |
Type: logical. Whether the force garbage collection at the end of each matrix construction in order to reclaim RAM. Defaults to |
progress_bar |
Type: logical. Whether to print a progress bar in case of list inputs. Defaults to |
... |
More arguments to pass to |
The lgb.Dataset
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | library(Matrix)
library(lightgbm)
set.seed(0)
# Generate lgb.Dataset from matrix
random_mat <- matrix(runif(10000, 0, 1), nrow = 1000)
random_labels <- runif(1000, 0, 1)
lgb_from_mat <- Laurae.lgb.dmat(data = random_mat, label = random_labels, missing = NA)
# Generate lgb.Dataset from data.frame
random_df <- data.frame(random_mat)
random_labels_2 <- runif(1000, 0, 1)
lgb_from_df <- Laurae.lgb.dmat(data = random_df, label = random_labels, missing = NA)
# Generate lgb.Dataset from respective elements of a list with progress bar
# while keeping memory usage as low as theoretically possible
random_list <- list(random_mat, random_df)
random_labels_3 <- list(random_labels, random_labels_2)
lgb_from_list <- Laurae.lgb.dmat(data = random_list,
label = random_labels_3,
missing = NA,
progress_bar = TRUE,
clean_mem = TRUE)
# Generate lgb.Dataset from respective elements of a list and keep only first
# while keeping memory usage as low as theoretically possible
lgb_from_list <- Laurae.lgb.dmat(data = random_list,
label = random_labels_3,
missing = NA,
save_keep = c(TRUE, FALSE),
clean_mem = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.