Commit 09ac3485 authored by Laurae's avatar Laurae Committed by Guolin Ke
Browse files

[R-package] Prevent remembering parameters (#796)

* 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
parent 6e3e1ec2
Dataset <- R6Class( Dataset <- R6Class(
classname = "lgb.Dataset", classname = "lgb.Dataset",
cloneable = FALSE, cloneable = TRUE,
public = list( 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 will free up the handles
finalize = function() { finalize = function() {
...@@ -276,6 +279,9 @@ Dataset <- R6Class( ...@@ -276,6 +279,9 @@ Dataset <- R6Class(
stop("lgb.Dataset.construct: label should be set") stop("lgb.Dataset.construct: label should be set")
} }
# Forcefully block construction
self$remodel <- FALSE
# Return self # Return self
return(invisible(self)) return(invisible(self))
......
...@@ -153,7 +153,10 @@ lgb.train <- function(params = list(), ...@@ -153,7 +153,10 @@ lgb.train <- function(params = list(),
} }
# Construct datasets, if needed # Construct datasets, if needed
data$construct() if (data$remodel == TRUE) {
data <- data$clone(deep = FALSE)
data$construct()
}
vaild_contain_train <- FALSE vaild_contain_train <- FALSE
train_data_name <- "train" train_data_name <- "train"
reduced_valid_sets <- list() reduced_valid_sets <- list()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment