Skip to content

[Bug]: xgboost in R  #208

Open
Open

Description

@Forwardlee0

Describe the bug

In R, when I set the learner to "regr.xgboost", I get the following error:
Error in y[] <- lapply(y, reallocate) :
ALTLIST classes must provide a Set_elt method [class: XGBAltrepPointerClass, pkg: xgboost]

My OS is macos and the xgboost package in R was installed via the R CMD INSTALL . instead of the CRAN.

Minimum reproducible code snippet

library(DoubleML)
library(mlr3)
library(mlr3learners)
library(data.table)
set.seed(2)
ml_g = lrn("regr.xgboost", nthread = 2)
ml_m = ml_g$clone()
obj_dml_data = make_plr_CCDDHNR2018(alpha = 0.5)
dml_plr_obj = DoubleMLPLR$new(obj_dml_data, ml_g, ml_m)
dml_plr_obj$fit()
dml_plr_obj$summary()

Expected Result

dml_plr_obj$fit()

Actual Result

Error in y[] <- lapply(y, reallocate) :
ALTLIST classes must provide a Set_elt method [class: XGBAltrepPointerClass, pkg: xgboost]

Versions

sessionInfo()
R version 4.4.2 (2024-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.1.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Asia/Shanghai
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] compiler_4.4.2 tools_4.4.2

packageVersion('DoubleML')
[1] ‘1.0.1’
packageVersion('mlr3')
[1] ‘0.22.1’
packageVersion('xgboost')
[1] ‘2.1.2.1’

Activity

  1. PhilippBach commented on Nov 29, 2024

    @PhilippBach
    Member

    Hi @Forwardlee0 ,

    thanks! As you probably guessed, I cannot replicate it locally (Windows, using xgboost from CRAN) ..

    Have you tried to update the mlr3 and mlr3learners packages recently? I am not sure, but they issued some new releases which also crashed some of our checks, so maybe it's worth a try?
    What happens if you use the CRAN version of xgboost?

  2. Forwardlee0 commented on Nov 29, 2024

    @Forwardlee0
    Author

    In Windows, there is no problem with the implementation of "regr.xgboost". The reason why I use xgboost from github instead of cran is that for xgboost of R in macos, xgboost from github can implement parallel computing, but cran's xgboost cannot. In addition, using xgboost from github alone for regression analysis is no problem. The above error occurs only when xgboost is implemented in doubleml.

  3. Forwardlee0 commented on Nov 29, 2024

    @Forwardlee0
    Author

    All of the packages is the latest

  4. Forwardlee0 commented on Nov 29, 2024

    @Forwardlee0
    Author

    I implement the following code, it works well:
    library(mlr3)
    library(mlr3learners)
    library(data.table)

    task = tsk("mtcars")
    task$col_roles$target = "mpg"

    learner = lrn("regr.xgboost")

    learner$train(task)
    prediction = learner$predict(task)
    print(prediction)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions