Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:DistrictDataLabs Yellowbrick ROCAUC Visualizer

From Leeroopedia


Knowledge Sources
Domains Machine_Learning, Classification, Visualization
Last Updated 2026-02-08 00:00 GMT

Overview

Concrete tool for evaluating the discriminative ability of classifiers via ROC/AUC curve visualization, provided by the Yellowbrick library.

Description

The ROCAUC class is a classification score visualizer that renders Receiver Operating Characteristic curves and computes Area Under the Curve scores. It wraps a scikit-learn classifier and plots FPR vs. TPR curves for binary and multiclass classification problems. For binary classifiers, it can plot a single curve for the positive class or per-class curves for both positive and negative classes. For multiclass problems, it supports per-class curves as well as micro-averaged and macro-averaged aggregate curves. The visualizer stores the computed FPR, TPR, and AUC values in dictionaries keyed by class index or averaging strategy.

The companion quick method roc_auc() provides a one-call interface that instantiates the visualizer, fits the model, scores it, and displays the plot in a single function call.

Usage

Use ROCAUC when you need a visual assessment of how well a probabilistic classifier separates classes across all thresholds. Import it when building model evaluation pipelines, performing model comparison, or preparing diagnostic reports for binary or multiclass classifiers.

Code Reference

Source Location

  • Repository: yellowbrick
  • File: yellowbrick/classifier/rocauc.py
  • Class Lines: L184-362 (ROCAUC class)
  • Quick Method Lines: L530-725 (roc_auc function)

Signature

class ROCAUC(ClassificationScoreVisualizer):
    def __init__(
        self,
        estimator,
        ax=None,
        micro=True,
        macro=True,
        per_class=True,
        binary=False,
        classes=None,
        encoder=None,
        is_fitted="auto",
        force_model=False,
        **kwargs
    )

    def fit(self, X, y=None)

    def score(self, X, y=None)
def roc_auc(
    estimator,
    X_train,
    y_train,
    X_test=None,
    y_test=None,
    ax=None,
    micro=True,
    macro=True,
    per_class=True,
    binary=False,
    classes=None,
    encoder=None,
    is_fitted="auto",
    force_model=False,
    show=True,
    **kwargs
)

Import

from yellowbrick.classifier import ROCAUC
from yellowbrick.classifier.rocauc import roc_auc

I/O Contract

Inputs

Name Type Required Description
estimator sklearn classifier Yes A scikit-learn classifier with a predict_proba or decision_function method
ax matplotlib Axes No Axes object on which to draw the plot; uses current axes if not provided
micro bool No If True (default), plot the micro-averaged ROC curve across all classes
macro bool No If True (default), plot the macro-averaged ROC curve across all classes
per_class bool No If True (default), plot individual ROC curves for each class
binary bool No If True, shortcut that sets micro, macro, and per_class to False for simple binary display
classes list of str No Human-readable class labels for the legend
encoder dict or LabelEncoder No Mapping from target values to human-readable labels
is_fitted bool or str No Whether the estimator is already fitted; defaults to "auto"
force_model bool No If True, skip the classifier type check on the estimator

Outputs

Name Type Description
score_ float The ROC AUC score (micro or macro average, or base model score)
fpr dict Dictionary of false positive rate arrays keyed by class index or averaging method
tpr dict Dictionary of true positive rate arrays keyed by class index or averaging method
roc_auc dict Dictionary of AUC values keyed by class index or averaging method
ax matplotlib Axes The axes with the rendered ROC curves

Usage Examples

Basic Usage

from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from yellowbrick.classifier import ROCAUC
from yellowbrick.datasets import load_occupancy

X, y = load_occupancy()
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)

viz = ROCAUC(LogisticRegression())
viz.fit(X_train, y_train)
viz.score(X_test, y_test)
viz.show()

Quick Method

from sklearn.linear_model import LogisticRegression
from yellowbrick.classifier.rocauc import roc_auc
from yellowbrick.datasets import load_occupancy

X, y = load_occupancy()
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)

roc_auc(LogisticRegression(), X_train, y_train, X_test, y_test)

Related Pages

Implements Principle

Requires Environment

Page Connections

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