Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R] add reset_data in lgb.cv #1874

Merged
merged 2 commits into from
Dec 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion R-package/R/lgb.cv.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ CVBooster <- R6::R6Class(
#' type str represents feature names
#' @param callbacks list of callback functions
#' List of callback functions that are applied at each iteration.
#' @param free_boosters Boolean, setting it to TRUE (the default value) will free the Booster objects in cv-folds
#' @param ... other parameters, see Parameters.rst for more information. A few key parameters:
#' \itemize{
#' \item{boosting}{Boosting type. \code{"gbdt"} or \code{"dart"}}
Expand Down Expand Up @@ -87,6 +88,7 @@ lgb.cv <- function(params = list(),
categorical_feature = NULL,
early_stopping_rounds = NULL,
callbacks = list(),
free_boosters = TRUE,
...) {

# Setup temporary variables
Expand Down Expand Up @@ -303,7 +305,9 @@ lgb.cv <- function(params = list(),
if (env$met_early_stop) break

}

if (free_boosters) {
cv_booster$boosters = NULL
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Laurae2 is this enough to free the memories of boosters?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guolinke would anyone ever NOT want to free them? I'd rather just make this new behavior and leave the function signature the same. Adding flags to the code makes it harder to maintain, in my experience.

}
# Return booster
return(cv_booster)

Expand Down
2 changes: 2 additions & 0 deletions R-package/R/lgb.train.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#' @param categorical_feature list of str or int
#' type int represents index,
#' type str represents feature names
#' @param callbacks list of callback functions
#' List of callback functions that are applied at each iteration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this change related?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the doc of this parameter is misning, compared with lgb.cv.

#' @param reset_data Boolean, setting it to TRUE (not the default value) will transform the booster model into a predictor model which frees up memory and the original datasets
#' @param ... other parameters, see Parameters.rst for more information. A few key parameters:
#' \itemize{
Expand Down