0

I am using lightgbm in a mlr3 and wrangle Data uses functions from the dplyr.

The R session in RStudio crashes when i load library(dplyr).

library(dplyr) # crash if load 
library(mlr3)
library(mlr3learners.lightgbm)
task = mlr3::tsk("iris")
learner = mlr3::lrn("classif.lightgbm", objective = "multiclass")

learner$param_set$values = mlr3misc::insert_named(
  learner$param_set$values,
  list(
    "early_stopping_round" = 10,
    "learning_rate" = 0.1,
    "seed" = 17L,
    "metric" = "multi_logloss",
    "num_iterations" = 100,
    "num_class" = 3
  )
)

learner$train(task, row_ids = 1:120)
predictions = learner$predict(task, row_ids = 121:150)
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
BinhNN
  • 87
  • 7
  • Is there an error message? I'm getting a regular error if I take the lightgbm from the mlr3extralearners package (https://github.com/mlr-org/mlr3extralearners). – Michel Jul 22 '21 at 08:22
  • if i run step by step sequentially like above it get error "R session Aborted". If I load the lightgbm package in before load dplyr, I don't get the error. – BinhNN Jul 22 '21 at 10:15

1 Answers1

1

There is a known issue on Windows specifically (microsoft/LightGBM#4464), where the order of package loading can lead {lightgbm} to produce crashes. This issue is known to affect versions 3.0.0 to 3.2.1, and will be fixed in a future release.

If you are on Windows and installed the package from CRAN with install.packages("lightgbm"), use library(lightgbm) before loading any other packages in your R session, and you will not see crashes.

Alternatively, you can install a version of {lightgbm} which does not suffer from this issue with any of the following approaches

  1. Use a macOS or Linux system if one is available to you.
  2. Clone https://github.com/microsoft/LightGBM, apply the changes from https://github.com/microsoft/LightGBM/pull/4496, and then compile the package from source.
git submodule init
git submodule update --recursive
sh build-cran-package.sh
R CMD INSTALL lightgbm_*.tar.gz
  1. Clone https://github.com/microsoft/LightGBM and install the package using CMake and Visual Studio compilers.
git submodule init
git submodule update --recursive
Rscript build_r.R
James Lamb
  • 1,662
  • 12
  • 16