bigframes.ml.metrics.precision_score#
- bigframes.ml.metrics.precision_score(y_true: DataFrame | Series, y_pred: DataFrame | Series, *, pos_label: int | float | bool | str = 1, average: Literal['binary'] = 'binary') float[source]#
- bigframes.ml.metrics.precision_score(y_true: DataFrame | Series, y_pred: DataFrame | Series, *, pos_label: int | float | bool | str = 1, average: None = 'binary') Series
Compute the precision.
The precision is the ratio
tp / (tp + fp), wheretpis the number of true positives andfpthe number of false positives. The precision is intuitively the ability of the classifier not to label as positive a sample that is negative.The best value is 1 and the worst value is 0.
Examples:
>>> import bigframes.pandas as bpd >>> import bigframes.ml.metrics
>>> 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
- Parameters:
y_true – Series or DataFrame of shape (n_samples,) Ground truth (correct) target values.
y_pred – Series or DataFrame of shape (n_samples,) Estimated targets as returned by a classifier.
average – {‘micro’, ‘macro’, ‘samples’, ‘weighted’, ‘binary’} or None, default=’binary’ This parameter is required for multiclass/multilabel targets. Possible values are ‘None’, ‘micro’, ‘macro’, ‘samples’, ‘weighted’, ‘binary’. Only None and ‘binary’ is supported.
- Returns:
- float (if average is not None) or Series of float of shape (n_unique_labels,).
Precision of the positive class in binary classification or weighted average of the precision of each class for the multiclass task.
- Return type:
precision