Skip to contents

Train xgboost model

Usage

xgboost_train(params, data, nrounds, ...)

Arguments

params

A list of parameters.

data

Training data.

nrounds

The Maximum number of boosting iterations.

...

Additional parameters.

Value

A model object.

Examples

sim_data <- msaenet::msaenet.sim.binomial(
  n = 100,
  p = 10,
  rho = 0.6,
  coef = rnorm(5, mean = 0, sd = 10),
  snr = 1,
  p.train = 0.8,
  seed = 42
)

x_train <- xgboost_dmatrix(sim_data$x.tr, label = sim_data$y.tr)

fit <- xgboost_train(
  params = list(
    objective = "binary:logistic",
    eval_metric = "auc",
    max_depth = 3,
    eta = 0.1
  ),
  data = x_train,
  nrounds = 100,
  nthread = 1
)

fit
#> ##### xgb.Booster
#> raw: 100.1 Kb 
#> call:
#>   xgboost::xgb.train(params = list(objective = "binary:logistic", 
#>     eval_metric = "auc", max_depth = 3, eta = 0.1), data = <pointer: 0x559fc8dc3390>, 
#>     nrounds = 100, nthread = 1)
#> params (as set within xgb.train):
#>   objective = "binary:logistic", eval_metric = "auc", max_depth = "3", eta = "0.1", nthread = "1", validate_parameters = "TRUE"
#> xgb.attributes:
#>   niter
#> callbacks:
#>   cb.print.evaluation(period = print_every_n)
#> niter: 100
#> nfeatures : 10