Skip to content

Commit 85fefa2

Browse files
authored
docs: add code samples for ml.metrics.r2_score (#459)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/python-bigquery-dataframes/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes internal #330220122 🦕
1 parent 340f0b5 commit 85fefa2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

third_party/bigframes_vendored/sklearn/metrics/_regression.py

+12
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ def r2_score(y_true, y_pred, force_finite=True) -> float:
4242
these cases are replaced with 1.0 (perfect predictions) or 0.0 (imperfect
4343
predictions) respectively.
4444
45+
**Examples:**
46+
47+
>>> import bigframes.pandas as bpd
48+
>>> import bigframes.ml.metrics
49+
>>> bpd.options.display.progress_bar = None
50+
51+
>>> y_true = bpd.DataFrame([3, -0.5, 2, 7])
52+
>>> y_pred = bpd.DataFrame([2.5, 0.0, 2, 8])
53+
>>> r2_score = bigframes.ml.metrics.r2_score(y_true, y_pred)
54+
>>> r2_score
55+
0.9486081370449679
56+
4557
Args:
4658
y_true (Series or DataFrame of shape (n_samples,)):
4759
Ground truth (correct) target values.

0 commit comments

Comments
 (0)