fit_one_xgb | R Documentation |
resamples
objectThis is the "workhorse" function called by the different methods of xgb_fit.
fit_one_xgb(
object,
resp,
expl,
params = list(),
nrounds,
verbose = 0,
weight = NULL,
threads = 1,
...
)
object |
of class resamples, created by a |
resp |
name of the response variable. |
expl |
names of the explanatory variables. |
params |
named list of parameters passed to |
nrounds |
number of boosting rounds (i.e. number of trees). |
verbose |
0 = silent, 1 = display performance, 2 = more verbose. |
weight |
a vector of observation-level weights, one per line of the training set. |
threads |
number of paralel threads used to fit each model. This is set
to 1 by default to avoid conflict with parallelisation per resample (in
|
... |
other parameters passed to 'xgboost::xgb.Train()“ |
The input object (a tibble of class resamples
) with an additional
column called model
containing the fitted model object.
# regression
rs <- resample_identity(mtcars, 1)
m <- fit_one_xgb(object=rs,
resp="mpg", expl=c("cyl", "hp", "qsec"),
eta=0.1, max_depth=4,
nrounds=20
)
m$model
# classification
mtcarsf <- mutate(mtcars, cyl=factor(cyl))
rs <- resample_identity(mtcarsf, 1)
m <- fit_one_xgb(object=rs,
resp="cyl", expl=c("mpg", "hp", "qsec"),
eta=0.1, max_depth=4,
nrounds=20
)
m$model
# parameters can also be passed as a list
m_list <- fit_one_xgb(object=rs,
resp="cyl", expl=c("mpg", "hp", "qsec"),
params=list(eta=0.1, max_depth=4),
nrounds=20
)
m$model[[1]]$params
m_list$model[[1]]$params
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.