Skip to content

Commit

Permalink
[R-package] Prevent remembering parameters (#796)
Browse files Browse the repository at this point in the history
* Enable simple cloning of dataset

* Add remodel logical to Dataset

* Allow remodeling of data

* Missing comma

* Use name instead of assignment for R6 class

* There should be no need to deep copy ALL objects
  • Loading branch information
Laurae2 authored and guolinke committed Aug 18, 2017
1 parent 6e3e1ec commit 09ac348
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion R-package/R/lgb.Dataset.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
Dataset <- R6Class(
classname = "lgb.Dataset",
cloneable = FALSE,
cloneable = TRUE,
public = list(

# Logical to check whether a dataset can be used re-modeled in-memory as another Dataset or not
remodel = TRUE,

# Finalize will free up the handles
finalize = function() {

Expand Down Expand Up @@ -276,6 +279,9 @@ Dataset <- R6Class(
stop("lgb.Dataset.construct: label should be set")
}

# Forcefully block construction
self$remodel <- FALSE

# Return self
return(invisible(self))

Expand Down
5 changes: 4 additions & 1 deletion R-package/R/lgb.train.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ lgb.train <- function(params = list(),
}

# Construct datasets, if needed
data$construct()
if (data$remodel == TRUE) {
data <- data$clone(deep = FALSE)
data$construct()
}
vaild_contain_train <- FALSE
train_data_name <- "train"
reduced_valid_sets <- list()
Expand Down

0 comments on commit 09ac348

Please sign in to comment.