Implementation:Scikit learn Scikit learn PlottingBase
| Knowledge Sources | |
|---|---|
| Domains | Machine Learning, Visualization |
| Last Updated | 2026-02-08 15:00 GMT |
Overview
Concrete utility mixin class for binary classifier curve display plots provided by scikit-learn.
Description
The _plotting module provides the _BinaryClassifierCurveDisplayMixin class, which centralizes validation logic for display classes that require a binary classifier. It handles estimator response extraction, prediction validation, cross-validation result processing, and matplotlib axis management for ROC curves, precision-recall curves, and similar binary classification visualizations.
Usage
Use this mixin as a base class when creating display objects for binary classifier evaluation curves. It provides standard from_estimator, from_predictions, and from_cv_results validation patterns.
Code Reference
Source Location
- Repository: scikit-learn
- File: sklearn/utils/_plotting.py
Signature
class _BinaryClassifierCurveDisplayMixin:
def _validate_plot_params(self, *, ax=None, name=None):
...
@classmethod
def _validate_and_get_response_values(
cls, estimator, X, y, *, response_method="auto", pos_label=None, name=None
):
...
@classmethod
def _validate_from_predictions_params(
cls, y_true, y_pred, *, sample_weight=None, pos_label=None, name=None
):
...
@classmethod
def _validate_from_cv_results_params(cls, cv_results, X, y, *, sample_weight):
...
Import
from sklearn.utils._plotting import _BinaryClassifierCurveDisplayMixin
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| estimator | estimator instance | Yes | A fitted binary classifier |
| X | array-like | Yes | Input features for prediction |
| y | array-like | Yes | True binary labels |
| response_method | str | No | Method to call on estimator ("auto", "predict_proba", "decision_function") |
| pos_label | int, float, bool, or str | No | The positive class label |
| ax | matplotlib Axes | No | Axes object to plot on |
Outputs
| Name | Type | Description |
|---|---|---|
| y_pred | ndarray | Predicted response values for the positive class |
| pos_label | object | The resolved positive label |
| name | str | Display name for the estimator |
Usage Examples
Basic Usage
from sklearn.metrics import RocCurveDisplay
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import make_classification
X, y = make_classification(random_state=42)
clf = LogisticRegression().fit(X, y)
display = RocCurveDisplay.from_estimator(clf, X, y)