bonsai icon indicating copy to clipboard operation
bonsai copied to clipboard

add support for case weights with lightgbm engine

Open nipnipj opened this issue 2 years ago • 6 comments

How we add weight to labels within bonsai? Does add_case_weights() work with bonsai?

nipnipj avatar Apr 09 '23 16:04 nipnipj

Could you clarify which engine/model supported by bonsai this question is in reference to?

simonpcouch avatar Apr 10 '23 12:04 simonpcouch

I'not sure. I mean LGBM supports weights through weight_column parameter, and a workflow using parsnip supports add_case_weights(). I thought I could use add_case_weights function with bonsai. It seems I was wrong.

What's the correct way to add weights to cases/classes with bonsai?

nipnipj avatar Apr 10 '23 16:04 nipnipj

Ah, gotcha! We ought to add support for that lightgbm parameter but have not yet. This will be included in a future release!

Note to self: reading through docs, this might be a bit tricky:

Note: works only in case of loading data directly from text file

simonpcouch avatar Apr 10 '23 17:04 simonpcouch

@simonpcouch LightGBM supports passing weights directly as an in-memory vector. weight_column is a parameter that's intended only for when reading from a file, and really only when using the LightGBM CLI.

Here's an example of weighted training LightGBM using an in-memory vector of weights (no need to care about weight_column parameter): https://github.com/microsoft/LightGBM/blob/638014d5c56fb92396bd55f344a47e3f651a3cd4/R-package/demo/weight_param.R.

jameslamb avatar Apr 10 '23 17:04 jameslamb

Awesome, thanks! :)

simonpcouch avatar Apr 10 '23 18:04 simonpcouch

I've taken a crack at adding support for case_weight() 72

p-schaefer avatar Dec 14 '23 03:12 p-schaefer

Closed by #72.

simonpcouch avatar May 08 '24 16:05 simonpcouch