Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Scikit learn Scikit learn PlottingBase

From Leeroopedia


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

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)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment