xgb.trainfunction for a more advanced interface.
xgboost(data = NULL, label = NULL, missing = NULL, params = list(), nrounds, verbose = 1, print.every.n = 1L, early.stop.round = NULL, maximize = NULL, ...)
dgCMatrix, local data file or
Commonly used ones are:
objectiveobjective function, common ones are
binary:logisticlogistic regression for classification
etastep size of each boosting step
max.depthmaximum depth of the tree
nthreadnumber of thread used in training, if not set, all threads are used
demo/ for walkthrough example in R.
verbose>0. Default is 1 which means all messages are printed.
NULL, the early stopping function is not triggered. If set to an integer
k, training with a validation set will stop if the performance keeps getting worse consecutively for
early.stop.roundare set, then
maximizemust be set as well.
maximize=TRUEmeans the larger the evaluation score the better.
Parallelization is automatically enabled if
OpenMP is present.
Number of threads can also be manually specified via
data(agaricus.train, package='xgboost') data(agaricus.test, package='xgboost') train <- agaricus.train test <- agaricus.test bst <- xgboost(data = train$data, label = train$label, max.depth = 2, eta = 1, nthread = 2, nround = 2, objective = "binary:logistic") pred <- predict(bst, test$data)