Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: xgboost in R #208

Open
Forwardlee0 opened this issue Nov 29, 2024 · 4 comments
Open

[Bug]: xgboost in R #208

Forwardlee0 opened this issue Nov 29, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Forwardlee0
Copy link

Forwardlee0 commented Nov 29, 2024

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’

@Forwardlee0 Forwardlee0 added the bug Something isn't working label Nov 29, 2024
@PhilippBach
Copy link
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?

@Forwardlee0
Copy link
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.

@Forwardlee0
Copy link
Author

All of the packages is the latest

@Forwardlee0
Copy link
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
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants