Setup hyperparameters for LightGBM training.
Usage
setup_LightGBM(
max_nrounds = 1000L,
force_nrounds = NULL,
early_stopping_rounds = 10L,
num_leaves = 8L,
max_depth = -1L,
learning_rate = 0.01,
feature_fraction = 1,
subsample = 1,
subsample_freq = 1L,
lambda_l1 = 0,
lambda_l2 = 0,
max_cat_threshold = 32L,
min_data_per_group = 32L,
linear_tree = FALSE,
ifw = FALSE,
objective = NULL,
device_type = "cpu",
tree_learner = "serial",
force_col_wise = TRUE
)Arguments
- max_nrounds
Integer [1, Inf): Maximum number of boosting rounds.
- force_nrounds
Optional Integer [1, Inf): Use this many boosting rounds. Disables search for nrounds.
- early_stopping_rounds
Integer [1, Inf): Number of rounds without improvement to stop training.
- num_leaves
(Tunable) Integer [1, Inf): Maximum number of leaves in one tree.
- max_depth
(Tunable) Integer: Maximum depth of trees. -1 = no limit.
- learning_rate
(Tunable) Numeric (0, 1]: Learning rate.
- feature_fraction
(Tunable) Numeric (0, 1]: Fraction of features to use.
- subsample
(Tunable) Numeric (0, 1]: Fraction of data to use.
- subsample_freq
(Tunable) Integer [1, Inf): Frequency of subsample.
- lambda_l1
(Tunable) Numeric [0, Inf): L1 regularization.
- lambda_l2
(Tunable) Numeric [0, Inf): L2 regularization.
- max_cat_threshold
(Tunable) Integer [1, Inf): Maximum number of categories for categorical features.
- min_data_per_group
(Tunable) Integer [1, Inf): Minimum number of observations per categorical group.
- linear_tree
(Tunable) Logical: If TRUE, use linear trees.
- ifw
(Tunable) Logical: If TRUE, use Inverse Frequency Weighting in classification.
- objective
Optional Character: Objective function. NULL = set from outcome type.
- device_type
Character {"cpu", "gpu", "cuda"}: Compute device.
- tree_learner
Character {"serial", "feature", "data", "voting"}: Tree learner type.
- force_col_wise
Logical: Use only with CPU - If TRUE, force col-wise histogram building.
Details
Get more information from lightgbm::lgb.train.
nrounds is auto-tuned using early stopping (up to max_nrounds) unless
force_nrounds is set.
Examples
lightgbm_hyperparams <- setup_LightGBM(
max_nrounds = 500L,
learning_rate = tune_over(0.001, 0.01, 0.05), ifw = TRUE
)
lightgbm_hyperparams
#> <LightGBMHyperparameters>
#> hyperparameters:
#> max_nrounds: <int> 500
#> force_nrounds: <NUL> NULL
#> early_stopping_rounds: <int> 10
#> num_leaves: <int> 8
#> max_depth: <int> -1
#> learning_rate: <tune> 0.001, 0.01, 0.05
#> feature_fraction: <nmr> 1.00
#> subsample: <nmr> 1.00
#> subsample_freq: <int> 1
#> lambda_l1: <nmr> 0.00
#> lambda_l2: <nmr> 0.00
#> max_cat_threshold: <int> 32
#> min_data_per_group: <int> 32
#> linear_tree: <lgc> FALSE
#> ifw: <lgc> TRUE
#> objective: <NUL> NULL
#> device_type: <chr> cpu
#> tree_learner: <chr> serial
#> force_col_wise: <lgc> TRUE
#> nrounds: <NUL> NULL
#> best_iter: <NUL> NULL
#> tunable_hyperparameters: <chr> num_leaves, max_depth, learning_rate, feature_fraction, subsample, subsample_freq, lambda_l1, lambda_l2, max_cat_threshold, min_data_per_group, linear_tree, ifw
#> fixed_hyperparameters: <chr> max_nrounds, force_nrounds, early_stopping_rounds, objective, device_type, tree_learner, force_col_wise, nrounds, best_iter
#> tuned: <int> 0
#> resampled: <int> 0
#> n_workers: <int> 1
#>
#> Hyperparameters learning_rate and nrounds need tuning.