bigframes.ml.metrics.roc_curve#
- bigframes.ml.metrics.roc_curve(y_true: DataFrame | Series, y_score: DataFrame | Series, *, drop_intermediate: bool = True) Tuple[Series, Series, Series][source]#
Compute Receiver operating characteristic (ROC).
Examples:
>>> import bigframes.pandas as bpd >>> import bigframes.ml.metrics
>>> y_true = bpd.DataFrame([1, 1, 2, 2]) >>> y_score = bpd.DataFrame([0.1, 0.4, 0.35, 0.8]) >>> fpr, tpr, thresholds = bigframes.ml.metrics.roc_curve(y_true, y_score, drop_intermediate=False) >>> fpr 0 0.0 1 0.0 2 0.0 3 0.0 4 0.0 Name: fpr, dtype: Float64
>>> tpr 0 0.0 1 0.333333 2 0.5 3 0.833333 4 1.0 Name: tpr, dtype: Float64
>>> thresholds 0 inf 1 0.8 2 0.4 3 0.35 4 0.1 Name: thresholds, dtype: Float64
- Parameters:
y_true – Series or DataFrame of shape (n_samples,) True binary labels. If labels are not either {-1, 1} or {0, 1}, then pos_label should be explicitly given.
y_score – Series or DataFrame of shape (n_samples,) Target scores, can either be probability estimates of the positive class, confidence values, or non-thresholded measure of decisions (as returned by “decision_function” on some classifiers).
drop_intermediate – bool, default=True Default to True. Whether to drop some suboptimal thresholds which would not appear on a plotted ROC curve. This is useful in order to create lighter ROC curves.
- Returns:
- Increasing false positive rates such that element i is the false
positive rate of predictions with score >= thresholds[i].
- tpr:
Increasing true positive rates such that element i is the true positive rate of predictions with score >= thresholds[i].
- thresholds:
Decreasing thresholds on the decision function used to compute fpr and tpr. thresholds[0] represents no instances being predicted and is arbitrarily set to max(y_score) + 1.
- Return type:
fpr