-
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-package] Cannot pass CSR single-row for prediction #4966
Comments
Thanks for the report! Are you able to provide a minimal, reproducible example demonstrating this behavior? And can you elaborate on what "does not allow" means specifically? e.g., is there an error raised, does LightGBM just produce incorrect results, etc. We're grateful for your reports and happy to try to help resolve these things, but would really appreciate more details so that maintainers don't spend time guessing things that I suspect you already know. |
Reproducible example: library(lightgbm)
data("mtcars")
ds <- lgb.Dataset(as.matrix(mtcars[, -1]), label=mtcars[,1])
m <- lgb.train(data=ds, obj="regression")
library(Matrix)
m_pred <- as.matrix(mtcars[, -1])
m_pred <- m_pred[1, , drop=FALSE]
x_csc <- as(m_pred, "CsparseMatrix")
x_csr <- as(x_csc, "RsparseMatrix")
x_spv <- as(x_csc, "sparseVector")
predict(m, x_csc) ### fine, but slow
predict(m, x_csr) ### error
predict(m, x_spv) ### error By "not allows" I mean that it throws errors, because there is no code route to take the input data in those formats. |
Excellent, thanks very much for that! |
I've added this to #2302, where we document feature requests for this project. Per this project's policies, I'll close this issue for now. Anyone reading this who is interested in contributing this feature, leave a comment and it can be re-opened. |
This issue has been automatically locked since there has not been any recent activity since it was closed. |
When making predictions on a single row with sparse data, the Python interface for lightgbm allows passing the input as a sparse CSR matrix, and making predictions this way is faster/more efficient than with CSC format when the input is large. The R interface does not allow passing prediction-time inputs in CSR formats (package
Matrix
has classesdsparseVector
anddgRMatrix
for that).The text was updated successfully, but these errors were encountered: