A wrapper for xgboost::xgb.train() for use in
nadir::super_learner().
Usage
lnr_xgboost(
data,
formula,
weights = NULL,
nrounds = 1000,
xgb.params = xgboost::xgb.params(),
objective = NULL,
...
)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.
- xgb.params
An
xgboost::xgb.params()object, or a named list of parameters that can be passed toxgboost::xgb.params().- objective
Optional objective. If supplied, this is inserted into
xgb.params. For binary Super Learner fits,nadirsuppliesobjective = "binary:logistic"throughoutcome_type_dependent_args.- ...
Additional arguments passed to
xgboost::xgb.params().
Details
This version avoids the high-level xgboost::xgboost() wrapper and
instead uses the lower-level xgb.DMatrix() + xgb.train()
interface. This is more stable for programmatic Super Learner use because
xgb.train() supports the full range of XGBoost objectives.
Examples
lnr_xgboost(mtcars, mpg ~ hp, nrounds = 5)(mtcars)
#> [1] 20.91871 20.91871 22.07225 20.91871 19.23841 18.98325 15.27003 25.20769
#> [9] 22.07225 19.02122 19.02122 17.14740 17.14740 17.14740 13.99621 13.99621
#> [17] 15.27003 27.78719 26.87268 27.78719 21.16343 16.97057 16.97057 15.27003
#> [25] 19.23841 27.78719 24.87027 25.82568 16.05263 19.23841 16.05263 20.91871
lnr_xgboost(
mtcars,
am ~ cyl + disp + hp,
objective = "binary:logistic",
nrounds = 5
)(mtcars)
#> [1] 0.6155238 0.6155238 0.7153227 0.1350583 0.1350583 0.1350583 0.4025543
#> [8] 0.5570078 0.5570078 0.1350583 0.1350583 0.1350583 0.1350583 0.1350583
#> [15] 0.1350583 0.1350583 0.4025543 0.7153227 0.7153227 0.7153227 0.6084444
#> [22] 0.1350583 0.1350583 0.4025543 0.1350583 0.7153227 0.6084444 0.7618669
#> [29] 0.4025543 0.6155238 0.4025543 0.6642613
