Skip to content

Conversation

diditforlulz273
Copy link

@diditforlulz273 diditforlulz273 commented Aug 13, 2021

I hereby agree to the terms of the CLA available at [https://yandex.ru/legal/cla/?lang=en].

Adds a focal loss CPU implementation. Focal loss is widely used in classification tasks with highly imbalanced data.
Details can be found here:
https://arxiv.org/abs/1708.02002 - original paper
https://paperswithcode.com/method/focal-loss - 216 papers used it.

Possible problems:

  1. Never tested in GPU mode. (Although on CPU is being used already).
  2. Alpha and Gamma parameters are passed by user to loss, but hardcoded in metric. If the way I did it in loss is correct, I'll add it to the metric too.
  3. Not covered by tests.
  4. No documentation is written, intended use is through Python Catboost wrapper with parameters like
    "loss_function": "Focal:focal_alpha=0.75;focal_gamma=2.0"

curApprox += approxDelta[k];
}
const float w = hasWeight ? weight[k] : 1;
double FocalAlpha = 0.75;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary to pass these parameters into the metric somehow.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd better wait for maintainers' advice on how to do it in the most correct way(probably in the way I did it with loss params)

}
const float w = hasWeight ? weight[k] : 1;
double FocalAlpha = 0.75;
double FocalGamma = 2;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter too.

@kizill
Copy link
Member

kizill commented Oct 21, 2021

@arcadia-devtools Ship it!

@arcadia-devtools
Copy link
Collaborator

CLA already signed

@arcadia-devtools
Copy link
Collaborator

@kizill, internal review request created: 2097439

@kizill
Copy link
Member

kizill commented Jul 14, 2022

@arcadia-devtools Ship it!

@arcadia-devtools
Copy link
Collaborator

@kizill, internal review request updated: 2097439

@langkkl
Copy link

langkkl commented Jan 18, 2023

thanks your great job.
for catboost 1.0.6,metric.cpp should add a GetDescription method.

@andrey-khropov
Copy link
Member

Thank you for your contribution. Sorry for the long wait. I've merged this PR (the original author is preserved).
I'll add tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants