Skip to content

Commit 512e932

Browse files
authored
refactor: remove to_pandas in ml.metrics.roc_auc_score (#560)
* refactor: remove to_pandas in ml.metrics.roc_auc_score * fix mypy
1 parent 853c25e commit 512e932

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

bigframes/ml/metrics/_metrics.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,10 @@ def roc_auc_score(
161161

162162
fpr, tpr, _ = roc_curve(y_true_series, y_score_series, drop_intermediate=False)
163163

164-
# TODO(bmil): remove this once bigframes supports the necessary operations
165-
pd_fpr = fpr.to_pandas()
166-
pd_tpr = tpr.to_pandas()
167-
168164
# Use the trapezoid rule to compute the area under the ROC curve
169-
width_diff = pd_fpr.diff().iloc[1:].reset_index(drop=True)
170-
height_avg = (pd_tpr.iloc[:-1] + pd_tpr.iloc[1:].reset_index(drop=True)) / 2
171-
return (width_diff * height_avg).sum()
165+
width_diff = fpr.diff().iloc[1:].reset_index(drop=True)
166+
height_avg = (tpr.iloc[:-1] + tpr.iloc[1:].reset_index(drop=True)) / 2
167+
return typing.cast(float, (width_diff * height_avg).sum())
172168

173169

174170
roc_auc_score.__doc__ = inspect.getdoc(vendored_metrics_ranking.roc_auc_score)

0 commit comments

Comments
 (0)