Skip to content

Commit 497ddf3

Browse files
committed
FIX 6147: ensure that AUC is always a float
1 parent 613f1ad commit 497ddf3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sklearn/metrics/ranking.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ def auc(x, y, reorder=False):
100100
"the x array is not increasing: %s" % x)
101101

102102
area = direction * np.trapz(y, x)
103-
103+
if isinstance(area, np.memmap):
104+
# Reductions such as .sum used internally in np.trapz do not return a
105+
# scalar by default for numpy.memmap instances contrary to
106+
# regular numpy.ndarray instances.
107+
area = area.dtype.type(area)
104108
return area
105109

106110

0 commit comments

Comments
 (0)