sklearn.metrics
.RocCurveDisplay¶
-
class
sklearn.metrics.
RocCurveDisplay
(fpr, tpr, roc_auc, estimator_name)[source]¶ ROC Curve visualization.
It is recommend to use
plot_roc_curve
to create a visualizer. All parameters are stored as attributes.Read more in the User Guide.
- Parameters
fpr : ndarray
False positive rate.
tpr : ndarray
True positive rate.
roc_auc : float
Area under ROC curve.
estimator_name : str
Name of estimator.
Attributes
line_
(matplotlib Artist) ROC Curve.
ax_
(matplotlib Axes) Axes with ROC Curve.
figure_
(matplotlib Figure) Figure containing the curve.
Examples
>>> import matplotlib.pyplot as plt >>> import numpy as np >>> from sklearn import metrics >>> y = np.array([0, 0, 1, 1]) >>> pred = np.array([0.1, 0.4, 0.35, 0.8]) >>> fpr, tpr, thresholds = metrics.roc_curve(y, pred) >>> roc_auc = metrics.auc(fpr, tpr) >>> display = metrics.RocCurveDisplay(fpr=fpr, tpr=tpr, roc_auc=roc_auc, estimator_name='example estimator') >>> display.plot() >>> plt.show()
Methods
plot
([ax, name])Plot visualization
-
__init__
(fpr, tpr, roc_auc, estimator_name)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
plot
(ax=None, name=None, **kwargs)[source]¶ Plot visualization
Extra keyword arguments will be passed to matplotlib’s
plot
.- Parameters
ax : matplotlib axes, default=None
Axes object to plot on. If
None
, a new figure and axes is created.name : str, default=None
Name of ROC Curve for labeling. If
None
, use the name of the estimator.- Returns
display :
RocCurveDisplay
Object that stores computed values.