Skip to content

Commit 53602af

Browse files
authored
[R-package] clarify parameter documentation (fixes #4193) (#4202)
* [R-package] clarify parameter documentation * fixes to braces * linting
1 parent 8e126c8 commit 53602af

File tree

10 files changed

+79
-45
lines changed

10 files changed

+79
-45
lines changed

R-package/R/lgb.Dataset.R

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,22 @@ Dataset <- R6::R6Class(
730730
#' @description Construct \code{lgb.Dataset} object from dense matrix, sparse matrix
731731
#' or local file (that was created previously by saving an \code{lgb.Dataset}).
732732
#' @param data a \code{matrix} object, a \code{dgCMatrix} object or a character representing a filename
733-
#' @param params a list of parameters
734-
#' @param reference reference dataset
733+
#' @param params a list of parameters. See
734+
#' \href{https://lightgbm.readthedocs.io/en/latest/Parameters.html#dataset-parameters}{
735+
#' The "Dataset Parameters" section of the documentation} for a list of parameters
736+
#' and valid values.
737+
#' @param reference reference dataset. When LightGBM creates a Dataset, it does some preprocessing like binning
738+
#' continuous features into histograms. If you want to apply the same bin boundaries from an existing
739+
#' dataset to new \code{data}, pass that existing Dataset to this argument.
735740
#' @param colnames names of columns
736-
#' @param categorical_feature categorical features
737-
#' @param free_raw_data TRUE for need to free raw data after construct
741+
#' @param categorical_feature categorical features. This can either be a character vector of feature
742+
#' names or an integer vector with the indices of the features (e.g.
743+
#' \code{c(1L, 10L)} to say "the first and tenth columns").
744+
#' @param free_raw_data LightGBM constructs its data format, called a "Dataset", from tabular data.
745+
#' By default, that Dataset object on the R side does not keep a copy of the raw data.
746+
#' This reduces LightGBM's memory consumption, but it means that the Dataset object
747+
#' cannot be changed after it has been constructed. If you'd prefer to be able to
748+
#' change the Dataset object after construction, set \code{free_raw_data = FALSE}.
738749
#' @param info a list of information of the \code{lgb.Dataset} object
739750
#' @param ... other information to pass to \code{info} or parameters pass to \code{params}
740751
#'

R-package/R/lgb.train.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
#' @param valids a list of \code{lgb.Dataset} objects, used for validation
66
#' @param record Boolean, TRUE will record iteration message to \code{booster$record_evals}
77
#' @param colnames feature names, if not null, will use this to overwrite the names in dataset
8-
#' @param categorical_feature list of str or int
9-
#' type int represents index,
10-
#' type str represents feature names
8+
#' @param categorical_feature categorical features. This can either be a character vector of feature
9+
#' names or an integer vector with the indices of the features (e.g.
10+
#' \code{c(1L, 10L)} to say "the first and tenth columns").
1111
#' @param callbacks List of callback functions that are applied at each iteration.
1212
#' @param reset_data Boolean, setting it to TRUE (not the default value) will transform the
1313
#' booster model into a predictor model which frees up memory and the
1414
#' original datasets
15-
#' @param ... other parameters, see Parameters.rst for more information. A few key parameters:
15+
#' @param ... other parameters, see \href{https://lightgbm.readthedocs.io/en/latest/Parameters.html}{
16+
#' the "Parameters" section of the documentation} for more information. A few key parameters:
1617
#' \itemize{
1718
#' \item{\code{boosting}: Boosting type. \code{"gbdt"}, \code{"rf"}, \code{"dart"} or \code{"goss"}.}
1819
#' \item{\code{num_leaves}: Maximum number of leaves in one tree.}
1920
#' \item{\code{max_depth}: Limit the max depth for tree model. This is used to deal with
20-
#' overfit when #data is small. Tree still grow by leaf-wise.}
21+
#' overfitting. Tree still grow by leaf-wise.}
2122
#' \item{\code{num_threads}: Number of threads for LightGBM. For the best speed, set this to
2223
#' the number of real CPU cores(\code{parallel::detectCores(logical = FALSE)}),
2324
#' not the number of threads (most CPU using hyper-threading to generate 2 threads

R-package/R/lightgbm.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
#' @param data a \code{lgb.Dataset} object, used for training. Some functions, such as \code{\link{lgb.cv}},
66
#' may allow you to pass other types of data like \code{matrix} and then separately supply
77
#' \code{label} as a keyword argument.
8-
#' @param early_stopping_rounds int. Activates early stopping. Requires at least one validation data
9-
#' and one metric. If there's more than one, will check all of them
10-
#' except the training data. Returns the model with (best_iter + early_stopping_rounds).
11-
#' If early stopping occurs, the model will have 'best_iter' field.
8+
#' @param early_stopping_rounds int. Activates early stopping. When this parameter is non-null,
9+
#' training will stop if the evaluation of any metric on any validation set
10+
#' fails to improve for \code{early_stopping_rounds} consecutive boosting rounds.
11+
#' If training stops early, the returned model will have attribute \code{best_iter}
12+
#' set to the iteration number of the best iteration.
1213
#' @param eval evaluation function(s). This can be a character vector, function, or list with a mixture of
1314
#' strings and functions.
1415
#'
@@ -48,7 +49,8 @@
4849
#' @param obj objective function, can be character or custom objective function. Examples include
4950
#' \code{regression}, \code{regression_l1}, \code{huber},
5051
#' \code{binary}, \code{lambdarank}, \code{multiclass}, \code{multiclass}
51-
#' @param params List of parameters
52+
#' @param params a list of parameters. See \href{https://lightgbm.readthedocs.io/en/latest/Parameters.html}{
53+
#' the "Parameters" section of the documentation} for a list of parameters and valid values.
5254
#' @param verbose verbosity for output, if <= 0, also will disable the print of evaluation during training
5355
#' @section Early Stopping:
5456
#'

R-package/R/saveRDS.lgb.Booster.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#' @title saveRDS for \code{lgb.Booster} models
33
#' @description Attempts to save a model using RDS. Has an additional parameter (\code{raw})
44
#' which decides whether to save the raw model or not.
5-
#' @param object R object to serialize.
5+
#' @param object \code{lgb.Booster} object to serialize.
66
#' @param file a connection or the name of the file where the R object is saved to or read from.
77
#' @param ascii a logical. If TRUE or NA, an ASCII representation is written; otherwise (default),
88
#' a binary one is used. See the comments in the help for save.

R-package/man/lgb.Dataset.Rd

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

R-package/man/lgb.cv.Rd

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

R-package/man/lgb.train.Rd

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

R-package/man/lgb_shared_params.Rd

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

R-package/man/lightgbm.Rd

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

R-package/man/saveRDS.lgb.Booster.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)