From f3f2f5a9539660eef54b8eec5236fb926923d015 Mon Sep 17 00:00:00 2001 From: Guolin Ke Date: Sun, 8 Jan 2017 16:47:39 +0800 Subject: [PATCH] [R-package] add reset parameters for CV object --- R-package/R/lgb.cv.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/R-package/R/lgb.cv.R b/R-package/R/lgb.cv.R index f71bda303783..44d09fde0209 100644 --- a/R-package/R/lgb.cv.R +++ b/R-package/R/lgb.cv.R @@ -7,6 +7,12 @@ CVBooster <- R6Class( boosters=list(), initialize=function(x){ self$boosters <- x + }, + reset_parameter=function(new_paramas){ + for(x in boosters){ + x$reset_parameter(new_paramas) + } + return(self) } ) ) @@ -270,7 +276,13 @@ lgb.stratified.folds <- function(y, k = 10) } lgb.merge.cv.result <- function(msg, showsd=TRUE){ + if(length(msg) == 0){ + stop("lgb.cv: size of cv result error") + } eval_len <- length(msg[[1]]) + if(eval_len == 0){ + stop("lgb.cv: should provide at least metric for CV") + } eval_result <- lapply(1:eval_len, function(j) { as.numeric(lapply(1:length(msg), function(i){ msg[[i]][[j]]$value