-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
(R) Functions that replace R headers are not compatible with all R versions #4216
Comments
Thanks very much for the write-up! I installed R 3.6.3 on my Mac tonight (macOS 10.14.6). I tried your reproducible example, and can confirm that if you call It also looks like changing the mode of the training data to double results in no trees being added. library(lightgbm)
data(mtcars)
X <- as.matrix(mtcars[,-1])
y = mtcars[,1,drop=TRUE]
# train on numeric data
m = lightgbm(X, y, params=list(objective="regression", min_data=1))
modelDT <- lightgbm::lgb.model.dt.tree(m)
head(modelDT)
# train on double data
mode(X) <- "double"
m <- lightgbm(X, y, params=list(objective="regression", min_data=1))
modelDT <- lightgbm::lgb.model.dt.tree(m)
head(modelDT) |
Linking #3016 |
This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
Migrated from here: #4207
The R interface for LightGBM has replacements for R's internal headers which re-define the structs used by R's variables. These underlying structures behind R objects are however not constant between versions, and currently the LighGBM replacements will not work correctly with R 3.6 for windows and mac (which from the requirements is meant to be supported, and is tested in the CI pipelines in github here).
Example:
print(pred_before)
print(pred_after)
(This was tested with R 3.6.3 and RTools35 on windows, but the problem will not be present if tested with R 4.0.4 in linux)
More concretely, what's failing there is the function
R_REAL_PTR(lightbm_struct)
(meant to obtain a pointer to the array ofdouble
s underneath an R matrix or vector), which does not output the same as the R C functionREAL(SEXP)
, returning instead a pointer to the address of some other array or struct. This not only causes incorrect results but can also lead to segmentation faults.For now I think an easy solution would be to require R >= 4.0.0, but this is not a real solution as the structs can change at any time as the R headers are not meant to be replaced by libraries.
The text was updated successfully, but these errors were encountered: