Skip to content

Commit 853c25e

Browse files
authored
feat: add ml.metrics.mean_squared_error (#559)
* feat: add ml.metrics.mean_squared_error * fix docs * fix docs
1 parent 90bcec5 commit 853c25e

File tree

4 files changed

+95
-69
lines changed

4 files changed

+95
-69
lines changed

bigframes/ml/metrics/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
auc,
1919
confusion_matrix,
2020
f1_score,
21+
mean_squared_error,
2122
precision_score,
2223
r2_score,
2324
recall_score,
@@ -35,5 +36,6 @@
3536
"confusion_matrix",
3637
"precision_score",
3738
"f1_score",
39+
"mean_squared_error",
3840
"pairwise",
3941
]

bigframes/ml/metrics/_metrics.py

+14
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,17 @@ def f1_score(
335335

336336

337337
f1_score.__doc__ = inspect.getdoc(vendored_metrics_classification.f1_score)
338+
339+
340+
def mean_squared_error(
341+
y_true: Union[bpd.DataFrame, bpd.Series],
342+
y_pred: Union[bpd.DataFrame, bpd.Series],
343+
) -> float:
344+
y_true_series, y_pred_series = utils.convert_to_series(y_true, y_pred)
345+
346+
return (y_pred_series - y_true_series).pow(2).sum() / len(y_true_series)
347+
348+
349+
mean_squared_error.__doc__ = inspect.getdoc(
350+
vendored_metrics_regression.mean_squared_error
351+
)

0 commit comments

Comments
 (0)