diff --git a/DESCRIPTION b/DESCRIPTION index 220f3031c..f99c111dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: mlr3extralearners Title: Extra Learners For mlr3 -Version: 0.5.12 +Version: 0.5.13 Authors@R: c(person(given = "Raphael", family = "Sonabend", diff --git a/NEWS.md b/NEWS.md index 7fcf0a7c0..8140bc417 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# mlr3extralearners 0.5.13 + +* Fix `categorical_features` in {lightgbm} learners + # mlr3extralearners 0.5.12 * Patch for `lightgbm` updates diff --git a/R/learner_lightgbm_classif_lightgbm.R b/R/learner_lightgbm_classif_lightgbm.R index a61777260..b0716a63d 100644 --- a/R/learner_lightgbm_classif_lightgbm.R +++ b/R/learner_lightgbm_classif_lightgbm.R @@ -19,6 +19,7 @@ #' @details #' For categorical features either pre-process data by encoding columns or #' specify the categorical columns with the `categorical_feature` parameter. +#' For this learner please do not prefix the categorical feature with `name:`. #' #' @template seealso_learner #' @template example @@ -285,9 +286,12 @@ LearnerClassifLightGBM = R6Class("LearnerClassifLightGBM", dtrain = lightgbm::lgb.Dataset( data = as.matrix(task$data(rows = train_ids, cols = task$feature_names)), label = train_label, - free_raw_data = FALSE + free_raw_data = FALSE, + categorical_feature = pars$categorical_feature ) + pars$categorical_feature <- NULL + dtest = lightgbm::lgb.Dataset.create.valid( dataset = dtrain, data = as.matrix(task$data(rows = valid_ids, cols = task$feature_names)), @@ -318,9 +322,12 @@ LearnerClassifLightGBM = R6Class("LearnerClassifLightGBM", dtrain = lightgbm::lgb.Dataset( data = as.matrix(task$data(cols = task$feature_names)), label = train_label, - free_raw_data = FALSE + free_raw_data = FALSE, + categorical_feature = pars$categorical_feature ) + pars$categorical_feature <- NULL + if ("weights" %in% task$properties) { dtrain$setinfo("weight", task$weights$weight) } diff --git a/R/learner_lightgbm_regr_lightgbm.R b/R/learner_lightgbm_regr_lightgbm.R index 5c5355a2d..637c2cd6f 100644 --- a/R/learner_lightgbm_regr_lightgbm.R +++ b/R/learner_lightgbm_regr_lightgbm.R @@ -16,9 +16,9 @@ #' - Adjusted default: -1L #' - Reason for change: Prevents accidental conflicts with mlr messaging system. #' -#' @details #' For categorical features either pre-process data by encoding columns or #' specify the categorical columns with the `categorical_feature` parameter. +#' For this learner please do not prefix the categorical feature with `name:`. #' #' @template seealso_learner #' @template example @@ -233,9 +233,12 @@ LearnerRegrLightGBM = R6Class("LearnerRegrLightGBM", dtrain = lightgbm::lgb.Dataset( data = as.matrix(task$data(rows = train_ids, cols = task$feature_names)), label = as.matrix(task$data(rows = train_ids, cols = task$target_names)), - free_raw_data = FALSE + free_raw_data = FALSE, + categorical_feature = pars$categorical_feature ) + pars$categorical_feature <- NULL + valid_ids = task$row_roles$validation dtest = lightgbm::lgb.Dataset.create.valid( dataset = dtrain, @@ -258,9 +261,12 @@ LearnerRegrLightGBM = R6Class("LearnerRegrLightGBM", dtrain = lightgbm::lgb.Dataset( data = as.matrix(task$data(cols = task$feature_names)), label = as.matrix(task$data(cols = task$target_names)), - free_raw_data = FALSE + free_raw_data = FALSE, + categorical_feature = pars$categorical_feature ) + pars$categorical_feature <- NULL + if ("weights" %in% task$properties) { dtrain$setinfo("weight", task$weights$weight) }