Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add code samples for metrics.{recall_score, precision_score, f11_score} #502

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ def recall_score(

The best value is 1 and the worst value is 0.

**Examples:**

>>> import bigframes.pandas as bpd
>>> import bigframes.ml.metrics
>>> bpd.options.display.progress_bar = None

>>> y_true = bpd.DataFrame([0, 1, 2, 0, 1, 2])
>>> y_pred = bpd.DataFrame([0, 2, 1, 0, 0, 1])
>>> recall_score = bigframes.ml.metrics.recall_score(y_true, y_pred, average=None)
>>> recall_score
0 1
1 0
2 0
dtype: int64


Args:
y_true (Series or DataFrame of shape (n_samples,)):
Ground truth (correct) target values.
Expand All @@ -137,6 +153,7 @@ def recall_score(
default='binary'):
This parameter is required for multiclass/multilabel targets.
Possible values are 'None', 'micro', 'macro', 'samples', 'weighted', 'binary'.
Only average=None is supported.

Returns:
float (if average is not None) or Series of float of shape n_unique_labels,): Recall
Expand All @@ -160,6 +177,21 @@ def precision_score(

The best value is 1 and the worst value is 0.

**Examples:**

>>> import bigframes.pandas as bpd
>>> import bigframes.ml.metrics
>>> bpd.options.display.progress_bar = None

>>> y_true = bpd.DataFrame([0, 1, 2, 0, 1, 2])
>>> y_pred = bpd.DataFrame([0, 2, 1, 0, 0, 1])
>>> precision_score = bigframes.ml.metrics.precision_score(y_true, y_pred, average=None)
>>> precision_score
0 0.666667
1 0.000000
2 0.000000
dtype: float64

Args:
y_true: Series or DataFrame of shape (n_samples,)
Ground truth (correct) target values.
Expand All @@ -169,6 +201,7 @@ def precision_score(
default='binary'
This parameter is required for multiclass/multilabel targets.
Possible values are 'None', 'micro', 'macro', 'samples', 'weighted', 'binary'.
Only average=None is supported.

Returns:
precision: float (if average is not None) or Series of float of shape \
Expand All @@ -195,6 +228,21 @@ def f1_score(
the F1 score of each class with weighting depending on the ``average``
parameter.

**Examples:**

>>> import bigframes.pandas as bpd
>>> import bigframes.ml.metrics
>>> bpd.options.display.progress_bar = None

>>> y_true = bpd.DataFrame([0, 1, 2, 0, 1, 2])
>>> y_pred = bpd.DataFrame([0, 2, 1, 0, 0, 1])
>>> f1_score = bigframes.ml.metrics.f1_score(y_true, y_pred, average=None)
>>> f1_score
0 0.8
1 0.0
2 0.0
dtype: float64

Args:
y_true: Series or DataFrame of shape (n_samples,)
Ground truth (correct) target values.
Expand Down