Skip to content

Commit b200877

Browse files
authored
[R] Update docs for custom user functions (dmlc#10328)
1 parent 0058301 commit b200877

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

R-package/R/xgb.train.R

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,23 @@
122122
#' printed out during the training.
123123
#' E.g., specifying \code{evals=list(validation1=mat1, validation2=mat2)} allows to track
124124
#' the performance of each round's model on mat1 and mat2.
125-
#' @param obj customized objective function. Returns gradient and second order
126-
#' gradient with given prediction and dtrain.
127-
#' @param feval customized evaluation function. Returns
128-
#' \code{list(metric='metric-name', value='metric-value')} with given
129-
#' prediction and dtrain.
125+
#' @param obj customized objective function. Should take two arguments: the first one will be the
126+
#' current predictions (either a numeric vector or matrix depending on the number of targets / classes),
127+
#' and the second one will be the `data` DMatrix object that is used for training.
128+
#'
129+
#' It should return a list with two elements `grad` and `hess` (in that order), as either
130+
#' numeric vectors or numeric matrices depending on the number of targets / classes (same
131+
#' dimension as the predictions that are passed as first argument).
132+
#' @param feval customized evaluation function. Just like `obj`, should take two arguments, with
133+
#' the first one being the predictions and the second one the `data` DMatrix.
134+
#'
135+
#' Should return a list with two elements `metric` (name that will be displayed for this metric,
136+
#' should be a string / character), and `value` (the number that the function calculates, should
137+
#' be a numeric scalar).
138+
#'
139+
#' Note that even if passing `feval`, objectives also have an associated default metric that
140+
#' will be evaluated in addition to it. In order to disable the built-in metric, one can pass
141+
#' parameter `disable_default_eval_metric = TRUE`.
130142
#' @param verbose If 0, xgboost will stay silent. If 1, it will print information about performance.
131143
#' If 2, some additional information will be printed out.
132144
#' Note that setting \code{verbose > 0} automatically engages the

R-package/man/xgb.train.Rd

Lines changed: 19 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)