Fix binary AUC calculation for boolean labels
* Fix binary AUC calculation when labels are bool.
Converting y_score to int using label_binarizer just like y_true.
* Optional binarization for y_score
@@ -158,6 +158,8 @@ def _daal_roc_auc_score(
if _dal_ready:
if not np.array_equal(labels, [0, 1]) or labels.dtype == bool:
y_true = label_binarize(y_true, classes=labels)[:, 0]
+ if hasattr(y_score, 'dtype') and y_score.dtype == bool:
+ y_score = label_binarize(y_score, classes=labels)[:, 0]
result = d4p.daal_roc_auc_score(y_true.reshape(-1, 1),
y_score.reshape(-1, 1))
if result != -1:
