Skip to content

Commit

Permalink
docs: add code samples for ml.metrics.r2_score (#459)
Browse files Browse the repository at this point in the history
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 🦕
  • Loading branch information
ashleyxuu authored Mar 19, 2024
1 parent 340f0b5 commit 85fefa2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions third_party/bigframes_vendored/sklearn/metrics/_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ def r2_score(y_true, y_pred, force_finite=True) -> float:
these cases are replaced with 1.0 (perfect predictions) or 0.0 (imperfect
predictions) respectively.
**Examples:**
>>> import bigframes.pandas as bpd
>>> import bigframes.ml.metrics
>>> bpd.options.display.progress_bar = None
>>> y_true = bpd.DataFrame([3, -0.5, 2, 7])
>>> y_pred = bpd.DataFrame([2.5, 0.0, 2, 8])
>>> r2_score = bigframes.ml.metrics.r2_score(y_true, y_pred)
>>> r2_score
0.9486081370449679
Args:
y_true (Series or DataFrame of shape (n_samples,)):
Ground truth (correct) target values.
Expand Down

0 comments on commit 85fefa2

Please sign in to comment.