I'm trying to model a forecasting problem where I'm trying to forecast for the following month. I am using LightGBM
Regressor class for it and it giving me a decent result in terms of actual Vs. predicted and mean_absolute_error
. There is one category of samples in my training set that I really want to improve on and bring down the mean_absolute_error
and I was thinking if I can penalize the model when it is wrong on that category of samples I might be able to achieve better results. Is there a way to pass sample weights to LGBMRegressor
or any sklearn
's regression class where perhaps the cost function is weighted sum of square
cost function?
$\begingroup$
$\endgroup$
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
3
Yes, you pass a sample_weight
to the LGBMRegressor().fit() method. See documentation on LGBMRegressor, section Methods:
-
$\begingroup$ thank you so much. I didn't realize that it was to be passed in the
fit
method. Do you know how know howLightGBM
uses these weights? Will simple theSum of sqaure
error to weightedSum of Sqaure
by weighing or multiplying each sample error to its respective weight in the array? $\endgroup$ Commented Oct 20, 2023 at 21:21 -
1$\begingroup$ No, I don't think its that straitforward, according the the LightGBM paper proceedings.neurips.cc/paper_files/paper/2017/file/… it has something to do with individual sample gradients, though I failed to understand the details. $\endgroup$ Commented Oct 21, 2023 at 22:35
-
$\begingroup$ Thank you for you help. I'll take a look. $\endgroup$ Commented Oct 23, 2023 at 13:29