A wrapper for lightgbm::lgb.train() for use in
nadir::super_learner().
Usage
lnr_lightgbm(
data,
formula,
weights = NULL,
nrounds = 100,
objective = NULL,
verbose = -1,
...
)Arguments
- data
A dataframe to train a learner / learners on.
- formula
A regression formula to use inside this learner.
- weights
Optional observation weights.
- nrounds
Number of boosting iterations.
- objective
Optional objective. For binary Super Learner fits,
nadirsuppliesobjective = "binary"throughoutcome_type_dependent_args. If unspecified, defaults to"regression".- verbose
(default: -1) Verbosity level passed to
lightgbm; -1 suppresses lightgbm's messages, larger values (0, 1, 2) show progressively more output.- ...
Additional named parameters passed into the
paramslist oflightgbm::lgb.train(), e.g.learning_rate,num_leaves,min_data_in_leaf.
Value
A prediction function that accepts newdata and returns a
numeric vector of predictions (probabilities of the outcome being 1
when objective = "binary"), one for each row of newdata.
Details
{lightgbm} does not have a formula interface, so internally this
learner constructs a numeric design matrix via
stats::model.matrix.lm() (as in lnr_xgboost) and trains on
that.
Note that min_data_in_leaf defaults to 1 here (rather than the
{lightgbm} default of 20) to account for the potential of very
small splits in cross-fitting; users can override this by passing
min_data_in_leaf explicitly.
Examples
lnr_lightgbm(mtcars, mpg ~ hp + wt, nrounds = 10)(mtcars)
#> [1] 20.68292 20.81318 21.43194 20.94345 18.04507 18.79409 16.31907 22.89741
#> [9] 21.85530 19.05462 19.05462 17.68684 17.58914 17.58914 13.77891 15.17925
#> [17] 15.17925 25.61125 27.94516 27.94516 21.43194 17.10065 18.04507 15.66774
#> [25] 19.51054 25.61125 25.61125 26.80534 17.29605 19.83620 16.77499 20.81318
lnr_lightgbm(mtcars, am ~ cyl + disp + hp,
objective = "binary",
nrounds = 10
)(mtcars)
#> [1] 0.7890306 0.7890306 0.7890306 0.1466812 0.1466812 0.1466812 0.3588241
#> [8] 0.1466812 0.1466812 0.1466812 0.1466812 0.1466812 0.1466812 0.1466812
#> [15] 0.1466812 0.1466812 0.1466812 0.7890306 0.7890306 0.7890306 0.1466812
#> [22] 0.1466812 0.1466812 0.3588241 0.1466812 0.7890306 0.7890306 0.7890306
#> [29] 0.3588241 0.7890306 0.7890306 0.7890306
