-
Notifications
You must be signed in to change notification settings - Fork 41
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 fix Lrnr_cv.R #422
base: devel
Are you sure you want to change the base?
Bug fix Lrnr_cv.R #422
Conversation
Previously, the following code, which contains a Stack of one learner, outputted a data.table containing NULLs with some entries a list of some subset of predictions. This bug is fixed here by replacing data.table(preds) with as.data.table(preds) n <- 500 W <- runif(n, -1 , 1) Y <- rbinom(n, 1, plogis(W)) task <- sl3_Task$new(data.table(W,Y), covariates = "W", outcome = "Y") Lrnr_cv$new(Stack$new(Lrnr_glm$new() ))$train(task)$predict(task)
Also, there are inconsistencies between the Lrnr_CV class method predict and the $base_predict method, which need to be addressed. In the Lrnr_CV class, the following code is present within the .predict method:
However, in $base_predict, the code is as follows:
If predictions is a data.table, then as.vector(predictions) would result in a list, not a vector, potentially leading to errors. This is good when predictions is a data.table with packed predictions but in settings where a numeric vector is expected, this is bad. To address this issue without affecting current behavior much, I propose the following change:
To preserve behavior, I try to output a numeric vector of predictions whenever possible. |
This was leading to errors with certain nested superlearners (Lrnr_sl). As a reproducible example, the following nested superlearner previously had malformed predictions/errors in the outer-level NNLS meta-regression.
|
Im also going to fix some bugs with Lrnr_pooled_hazards and Lrnr_independent binomial in this pull request |
previously Lrnr_cv$new(Lrnr_independent_binomial) would error because packed predictions were getting unlished in Lrnr_cv$predict To fix this, I changed
to
|
Thank you!! I found some issues w Lrnr_cv predictions recently (#404). Does this PR resolve this? |
I don't think this affects that PR. I left a comment what I think the issue is. @rachaelvp |
Added weights for GAM
Added weights support for Lrnr_gam (I thought this was already supported.) |
Previously, the following code, which contains a Stack of one learner, outputted a data.table containing NULLs with some entries a list of some subset of predictions.
This bug is fixed here by replacing data.table(preds) with as.data.table(preds) in the .predict function of Lrnr_cv.
As a note here, I think we should move away from using
data.table(object)
unless we deliberately want to have a data.table containing lists (e..g, as with packed predictions). In other cases,as.data.table
should be used.