added support for case_weights#72
Conversation
simonpcouch
left a comment
There was a problem hiding this comment.
A strong start! Some pointers to move this closer:
| #' @keywords internal | ||
| #' @export | ||
| train_lightgbm <- function(x, y, max_depth = -1, num_iterations = 100, learning_rate = 0.1, | ||
| train_lightgbm <- function(x, y,weights=NULL, max_depth = -1, num_iterations = 100, learning_rate = 0.1, |
There was a problem hiding this comment.
| train_lightgbm <- function(x, y,weights=NULL, max_depth = -1, num_iterations = 100, learning_rate = 0.1, | |
| train_lightgbm <- function(x, y, weights = NULL, max_depth = -1, num_iterations = 100, learning_rate = 0.1, |
Spaces after commas and before and after operators; could you apply this style elsewhere in the PR?
There was a problem hiding this comment.
There was a problem hiding this comment.
I think I've corrected these
| if (!is.null(val_index)) { | ||
| args$main$valids <- | ||
| list(validation = | ||
| lightgbm::lgb.Dataset( |
There was a problem hiding this comment.
There are a number of unrelated style edits in this PR like this one. Could you revert?
There was a problem hiding this comment.
I think I've corrected these? Let me know if thats not the case.
There was a problem hiding this comment.
Almost there. If you look in this diff, there are several spaces before the function call and arguments that didn't used to be there.
…er vector specifying one or more variables in `x`used for grouping observations with the same value to either the training or validation set.
|
Thanks for the review @simonpcouch. Note, I am also working on a method that allows some ability to customize validation data beyond just specifying a proportion of training data. I find this quite necessary for my work (since my data are not entirely independent - hence needing case weights as well), but I don't know if its robust enough to include in Bonsai proper. |
| # this function ensures that multiclass classification predictions are always | ||
| # returned as a [num_observations, num_classes] matrix, regardless of lightgbm version | ||
| reshape_lightgbm_multiclass_preds <- function(preds, num_rows) { | ||
| n_preds_per_case <- length(preds) / num_rows |
There was a problem hiding this comment.
More space deletions here that are unrelated to the PR.
| p <- stats::predict(object$fit, prepare_df_lgbm(new_data), type = "raw", ...) | ||
| p <- stats::predict(object$fit, prepare_df_lgbm(new_data), type = "raw", ...) | ||
| } else { | ||
| p <- stats::predict(object$fit, prepare_df_lgbm(new_data), rawscore = TRUE, ...) |
There was a problem hiding this comment.
This file, lightgbm.new.md, is an intermediate file from testthat. To merge its changes into the existing test-lightgbm.R, use testthat::snapshot_accept().
|
Thanks again for your work here. Given the lack of movement on this PR, I'm going to go ahead and close. :) |
|
I have found a need for this feature recently, so I may try to resurrect this pull request and finish cleaning it up sometime this week. Anything I should know besides your comments above, @simonpcouch ? |
|
That'd be wonderful, @joranE! Conceptually, the implementation here looks solid—following the current review comments would put this PR in a good spot. |
|
Sorry, this fell off my radar. I can finish addressing the comments next week, if that works for you.
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Simon P. Couch ***@***.***>
Sent: Monday, April 8, 2024 9:31:10 AM
To: tidymodels/bonsai ***@***.***>
Cc: Patrick Schaefer ***@***.***>; Author ***@***.***>
Subject: Re: [tidymodels/bonsai] added support for case_weights (PR #72)
That'd be wonderful, @joranE<https://github.com/joranE>! Conceptually, the implementation here looks solid—following the current review comments would put this PR in a good spot.
—
Reply to this email directly, view it on GitHub<#72 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACYA7SXU5VRFVBVDIZ322P3Y4KLZ5AVCNFSM6AAAAABAUFJUD6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBSG43DONJYGY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
|
@p-schaefer Sounds good, I'll let you tackle it! If you find yourself pulled away from it again for any reason, just let me know. |
|
I've fixed the spacing issues, and dealt with the intermediate file from testthat. Should I submit a new PR? |
|
You're welcome to push to the same branch! I'll reopen this one. |
|
Sorry, forgot to rerun the tests and checks. Looks good to me now, let me know if there is anything else. |
|
Thanks for closing the loop on this @p-schaefer! Now I just need to figure out if there's an easy way to tweak this interface to allow for the use of the |
|
No problem. It might be worth opening a new issue to discuss how to deal with |
|
I added a new issue here. |
|
Test failures are unrelated, feel free to ignore. :) |
|
@simonpcouch Was there anything else you need from me? |
|
Nice work, @p-schaefer! :) |
I noticed there wasn't much progress on integrating case_weights into lightgbm through bonsai so I've taken a crack at adding it. This is in reference to 65.