Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Precision Recall AUC as an metric for binary classification #3026

Closed
kdlin opened this issue Apr 27, 2020 · 3 comments
Closed

Add Precision Recall AUC as an metric for binary classification #3026

kdlin opened this issue Apr 27, 2020 · 3 comments

Comments

@kdlin
Copy link

kdlin commented Apr 27, 2020

For binary classification problems, Precision Recall AUC (as opposed to ROC AUC) is a good metric for unbalanced data. Currently, I have to use a custom eval function even though I use logloss as the ojective function. As a result, both logloss and PR-AUC are used to stop training. (I use early_stopping_rounds= 25 to stop the iterations.)

I would like to stop the iterations with just PR-AUC as the metric. Using custom eval function slows down the speed of LightGBM too. Additionally, XGBoost has PR-AUC as a metric. (They called it aucpr.)

I propose that PR-AUC to be added as a built-in metric.

My workaround is as follows for the time being:

model=lgb.train(params, lgb_train,
num_boost_round=2000,
valid_sets=[lgb_valid],
feval=f_pr_auc,
early_stopping_rounds=25,
verbose_eval=50)

def pr_auc(y_true, probas_pred):
p, r, _ = precision_recall_curve(y_true, probas_pred)
return auc(r, p)

def f_pr_auc(probas_pred, y_true):
probas_pred=sigmoid(probas_pred)
labels=y_true.get_label()
p, r, _ = precision_recall_curve(labels, probas_pred)
score=auc(r,p)
return "pr_auc", score, True

@btrotta
Copy link
Collaborator

btrotta commented May 7, 2020

Closed in favor of being in #2302. PR is welcome for this feature!

@btrotta
Copy link
Collaborator

btrotta commented Sep 2, 2020

Reopened since there is an active PR.

@btrotta btrotta reopened this Sep 2, 2020
@StrikerRUS
Copy link
Collaborator

Closed via #3347.

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

No branches or pull requests

3 participants