@@ -25,8 +25,6 @@ CVBooster <- R6::R6Class(
2525# ' @description Cross validation logic used by LightGBM
2626# ' @inheritParams lgb_shared_params
2727# ' @param nfold the original dataset is randomly partitioned into \code{nfold} equal size subsamples.
28- # ' @param label Deprecated. See "Deprecated Arguments" section below.
29- # ' @param weight Deprecated. See "Deprecated Arguments" section below.
3028# ' @param record Boolean, TRUE will record iteration message to \code{booster$record_evals}
3129# ' @param showsd \code{boolean}, whether to show standard deviation of cross validation.
3230# ' This parameter defaults to \code{TRUE}. Setting it to \code{FALSE} can lead to a
@@ -36,8 +34,6 @@ CVBooster <- R6::R6Class(
3634# ' @param folds \code{list} provides a possibility to use a list of pre-defined CV folds
3735# ' (each element must be a vector of test fold's indices). When folds are supplied,
3836# ' the \code{nfold} and \code{stratified} parameters are ignored.
39- # ' @param colnames Deprecated. See "Deprecated Arguments" section below.
40- # ' @param categorical_feature Deprecated. See "Deprecated Arguments" section below.
4137# ' @param callbacks List of callback functions that are applied at each iteration.
4238# ' @param reset_data Boolean, setting it to TRUE (not the default value) will transform the booster model
4339# ' into a predictor model which frees up memory and the original datasets
@@ -69,20 +65,12 @@ CVBooster <- R6::R6Class(
6965# ' )
7066# ' }
7167# '
72- # ' @section Deprecated Arguments:
73- # '
74- # ' A future release of \code{lightgbm} will require passing an \code{lgb.Dataset}
75- # ' to argument \code{'data'}. It will also remove support for passing arguments
76- # ' \code{'categorical_feature'}, \code{'colnames'}, \code{'label'}, and \code{'weight'}.
77- # '
7868# ' @importFrom data.table data.table setorderv
7969# ' @export
8070lgb.cv <- function (params = list ()
8171 , data
8272 , nrounds = 100L
8373 , nfold = 3L
84- , label = NULL
85- , weight = NULL
8674 , obj = NULL
8775 , eval = NULL
8876 , verbose = 1L
@@ -92,8 +80,6 @@ lgb.cv <- function(params = list()
9280 , stratified = TRUE
9381 , folds = NULL
9482 , init_model = NULL
95- , colnames = NULL
96- , categorical_feature = NULL
9783 , early_stopping_rounds = NULL
9884 , callbacks = list ()
9985 , reset_data = FALSE
@@ -104,33 +90,8 @@ lgb.cv <- function(params = list()
10490 if (nrounds < = 0L ) {
10591 stop(" nrounds should be greater than zero" )
10692 }
107-
108- # If 'data' is not an lgb.Dataset, try to construct one using 'label'
10993 if (! .is_Dataset(x = data )) {
110- warning(paste0(
111- " Passing anything other than an lgb.Dataset object to lgb.cv() is deprecated. "
112- , " Either pass an lgb.Dataset object, or use lightgbm()."
113- ))
114- if (is.null(label )) {
115- stop(" 'label' must be provided for lgb.cv if 'data' is not an 'lgb.Dataset'" )
116- }
117- data <- lgb.Dataset(data = data , label = label )
118- }
119-
120- # raise deprecation warnings if necessary
121- # ref: https://github.com/microsoft/LightGBM/issues/6435
122- args <- names(match.call())
123- if (" categorical_feature" %in% args ) {
124- .emit_dataset_kwarg_warning(" categorical_feature" , " lgb.cv" )
125- }
126- if (" colnames" %in% args ) {
127- .emit_dataset_kwarg_warning(" colnames" , " lgb.cv" )
128- }
129- if (" label" %in% args ) {
130- .emit_dataset_kwarg_warning(" label" , " lgb.cv" )
131- }
132- if (" weight" %in% args ) {
133- .emit_dataset_kwarg_warning(" weight" , " lgb.cv" )
94+ stop(" lgb.cv: data must be an lgb.Dataset instance" )
13495 }
13596
13697 # set some parameters, resolving the way they were passed in with other parameters
@@ -214,37 +175,17 @@ lgb.cv <- function(params = list()
214175 data $ construct()
215176
216177 # Check interaction constraints
217- cnames <- NULL
218- if (! is.null(colnames )) {
219- cnames <- colnames
220- } else if (! is.null(data $ get_colnames())) {
221- cnames <- data $ get_colnames()
222- }
223178 params [[" interaction_constraints" ]] <- .check_interaction_constraints(
224179 interaction_constraints = interaction_constraints
225- , column_names = cnames
180+ , column_names = data $ get_colnames()
226181 )
227182
228- if (! is.null(weight )) {
229- data $ set_field(field_name = " weight" , data = weight )
230- }
231-
232183 # Update parameters with parsed parameters
233184 data $ update_params(params = params )
234185
235186 # Create the predictor set
236187 data $ .__enclos_env__ $ private $ set_predictor(predictor = predictor )
237188
238- # Write column names
239- if (! is.null(colnames )) {
240- data $ set_colnames(colnames = colnames )
241- }
242-
243- # Write categorical features
244- if (! is.null(categorical_feature )) {
245- data $ set_categorical_feature(categorical_feature = categorical_feature )
246- }
247-
248189 if (! is.null(folds )) {
249190
250191 # Check for list of folds or for single value
0 commit comments