Skip to content

Commit 5de5743

Browse files
authored
Be more lenient on floating point error for AUC. (dmlc#10264)
1 parent f588252 commit 5de5743

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/metric/auc.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ double GroupRankingROC(Context const* ctx, common::Span<float const> predts,
177177
if (sum_w != 0) {
178178
auc /= sum_w;
179179
}
180-
CHECK_LE(auc, 1.0f);
180+
CHECK_LE(auc, 1.0 + kRtEps);
181181
return auc;
182182
}
183183

@@ -290,8 +290,8 @@ class EvalAUC : public MetricNoCache {
290290

291291
auc = collective::GlobalRatio(ctx_, info, auc, static_cast<double>(valid_groups));
292292
if (!std::isnan(auc)) {
293-
CHECK_LE(auc, 1) << "Total AUC across groups: " << auc * valid_groups
294-
<< ", valid groups: " << valid_groups;
293+
CHECK_LE(auc, 1.0 + kRtEps) << "Total AUC across groups: " << auc * valid_groups
294+
<< ", valid groups: " << valid_groups;
295295
}
296296
} else if (meta[0] != meta[1] && meta[1] % meta[0] == 0) {
297297
/**
@@ -311,7 +311,8 @@ class EvalAUC : public MetricNoCache {
311311
}
312312
auc = collective::GlobalRatio(ctx_, info, auc, fp * tp);
313313
if (!std::isnan(auc)) {
314-
CHECK_LE(auc, 1.0);
314+
CHECK_LE(auc, 1.0 + kRtEps);
315+
auc = std::min(auc, 1.0);
315316
}
316317
}
317318
if (std::isnan(auc)) {

0 commit comments

Comments
 (0)