SynapseML icon indicating copy to clipboard operation
SynapseML copied to clipboard

[LightGBM] Regression: how to penalize negative predictions

Open brunocous opened this issue 5 years ago • 18 comments

I have a simple regression task (using a LightGBMRegressor) where I want to penalize negative predictions more than positive ones. Is there a way to achieve this with the default regression LightGBM objectives (see https://lightgbm.readthedocs.io/en/latest/Parameters.html)? If not, is it somehow possible to define (many example for default LightGBM model) and pass a custom regression objective?

Thx in advance!

brunocous avatar Sep 02 '20 09:09 brunocous

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.

welcome[bot] avatar Sep 02 '20 09:09 welcome[bot]

The simplest way might be to duplicate positive examples in your training set so that they naturally carry more influence during training.

tyler-romero avatar Sep 02 '20 19:09 tyler-romero

"define (many example for default LightGBM model) and pass a custom regression objective" @brunocous unfortunately, we don't have this currently in the mmlspark wrapper of lightgbm, but it would definitely be a great feature to add at some point.

imatiach-msft avatar Sep 04 '20 17:09 imatiach-msft

I should update this thread that custom objectives have been added recently, so this should be possible now

imatiach-msft avatar Aug 18 '21 14:08 imatiach-msft

Hi @imatiach-msft could you let me know if I can work on this?

DefUs3r avatar Aug 22 '21 19:08 DefUs3r

@DefUs3r sure, what do you want to work on specifically? Are you thinking of adding an example on how to penalize negative predictions using a custom loss function?

imatiach-msft avatar Aug 23 '21 14:08 imatiach-msft

Hii @brunocous everything is almost fine on your provided link, but it could be more Attractive by using some more UI features, color schemes, and images. Also in your Python code learning, you can give the idea for them starting from the basics.

Mihir-Khandelwal avatar Aug 25 '21 12:08 Mihir-Khandelwal

@Mihir-Khandelwal are you commenting on the right thread? I think you might have meant to comment elsewhere?

imatiach-msft avatar Aug 25 '21 14:08 imatiach-msft

Can I be assigned this @imatiach-msft ?

pragyasrivastava0805 avatar Aug 27 '21 15:08 pragyasrivastava0805

@pragyasrivastava0805 sure, I just assigned the task to you

imatiach-msft avatar Aug 27 '21 15:08 imatiach-msft

@imatiach-msft i am very new to open source,could you please walk me through and tell what exactly needs to be done

pragyasrivastava0805 avatar Aug 27 '21 17:08 pragyasrivastava0805

@imatiach-msft Sorry i am new to this, as an microsoft recruting task, i was assigned a task to comment a code correction on any of the 100+ stars github account.

Mihir-Khandelwal avatar Aug 28 '21 02:08 Mihir-Khandelwal

I have a simple regression task (using a LightGBMRegressor) where I want to penalize negative predictions more than positive ones. Is there a way to achieve this with the default regression LightGBM objectives (see https://lightgbm.readthedocs.io/en/latest/Parameters.html)? If not, is it somehow possible to define (many example for default LightGBM model) and pass a custom regression objective?

Thx in advance!

I want to ask just for clarity purpose that here ,positive and negatives samples refer to overestimation and underestimation , correct?

navya002 avatar Aug 29 '21 08:08 navya002

I want to ask just for clarity purpose that here ,positive and negatives samples refer to overestimation and underestimation , correct?

Correct. In the end, I went with just using the quantile regression objective to penalise overestimations more. That worked well enough for my use case. Second trick that helped a lot is assigning samples that are more prone to overestimation a higher sample weight for training. Not perfect solutions, but it does the trick.

brunocous avatar Aug 30 '21 12:08 brunocous

Hi ,

Thanks for responding , that resonates with me as well. Also, while I was looking at it (the problem) I optimised objective function a bit for better results since in the 50th percent quantile it turns out to be mae , I changed it a bit for better results.Please have a look and let me know what you think (I have submitted the pull request with that function).

Hoping it helps and awaiting your reply.

Thankfully Navya

On Mon, Aug 30, 2021, 18:01 brunocous @.***> wrote:

I have a simple regression task (using a LightGBMRegressor) where I want to penalize negative predictions more than positive ones. Is there a way to achieve this with the default regression LightGBM objectives (see https://lightgbm.readthedocs.io/en/latest/Parameters.html)? If not, is it somehow possible to define (many example for default LightGBM model) and pass a custom regression objective? Thx in advance!

I want to ask just for clarity purpose that here ,positive and negatives samples refer to overestimation and underestimation , correct?

Correct. In the end, I went with just using the quantile regression objective to penalise overestimations more. That worked enough for my task at hand. Second trick that helped a lot is assigning samples more prone to overestimate a higher sample weight. Not perfect solutions, but it does the trick.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/microsoft/SynapseML/issues/918#issuecomment-908303142, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALH4H56VPQRNJKBSBFWUF53T7N22XANCNFSM4QS2APIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

navya002 avatar Aug 30 '21 12:08 navya002

I want to ask just for clarity purpose that here ,positive and negatives samples refer to overestimation and underestimation , correct?

Correct. In the end, I went with just using the quantile regression objective to penalise overestimations more. That worked well enough for my use case. Second trick that helped a lot is assigning samples more prone to overestimate a higher sample weight for training. Not perfect solutions, but it does the trick.

Please assign me this @brunocous @imatiach-msft

karnvaibhav11 avatar Aug 30 '21 22:08 karnvaibhav11

Hi, I have found a way to penalize the negative prediction in Regression by using the concepts of Adaboost penalization of wrong Classification Penalization. Basically what it does is, it updates the weight of the negative residual and increase its training example for the next model. This ensures that if the value is overestimated it penalizes it more. It's a completely new concept which I researched and the work is still in progress.
Please find the attached Docx. which has the steps that I followed and pdf for the code. Note that I haven't created the intervals due to the lack of time and to meet my Microsoft Project deadline. But I'll work on it later on. Also, I am unable to create a pull request so I am sharing these files over here. Will love to hear your feedback. Thanks.

Penalizing the Negative Prediction in a Regression Problem.docx M2LinearRegression.pdf

karnvaibhav11 avatar Aug 31 '21 11:08 karnvaibhav11

Penalizing.the.Negative.Prediction.in.a.Regression.Problem.docx

I have Created a pipeline using Azure ML for Regression Model

ParulSrivastava avatar Dec 05 '21 11:12 ParulSrivastava