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:DistrictDataLabs Yellowbrick DecisionBoundariesVisualizer

From Leeroopedia


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

Overview

Concrete tool for visualizing decision boundaries of classifiers in bivariate feature space, provided by the Yellowbrick contrib module.

Description

The DecisionBoundariesVisualizer renders the decision regions of a trained classifier as a colored mesh over a 2D feature grid. It overlays scatter points colored by class label and supports automatic feature column selection from DataFrames, structured arrays, and numpy arrays. The visualizer creates a meshgrid from the selected feature pair and uses the classifier's predictions to color the background.

Usage

Import this visualizer when you need to inspect how a classifier partitions bivariate feature space. It is particularly useful for understanding decision boundaries of models like SVM, KNN, and decision trees on two selected features.

Code Reference

Source Location

Signature

class DecisionBoundariesVisualizer(ClassificationScoreVisualizer):
    def __init__(
        self,
        estimator,
        ax=None,
        x_name=None,
        y_name=None,
        features=None,
        classes=None,
        show_scatter=True,
        step_size=0.0025,
        markers=None,
        pcolormesh_alpha=0.8,
        scatter_alpha=1.0,
        encoder=None,
        is_fitted="auto",
        force_model=False,
        **kwargs,
    ):
        """Bivariate decision boundary visualizer for classifiers."""

def decisionviz(
    estimator, X, y, ax=None, x_name=None, y_name=None,
    features=None, classes=None, show_scatter=True, step_size=0.0025,
    markers=None, pcolormesh_alpha=0.8, scatter_alpha=1.0,
    encoder=None, is_fitted="auto", force_model=False, **kwargs,
):
    """Quick method for one-off decision boundary visualization."""

# Alias
DecisionViz = DecisionBoundariesVisualizer

Import

from yellowbrick.contrib.classifier import DecisionBoundariesVisualizer, DecisionViz, decisionviz

I/O Contract

Inputs

Name Type Required Description
estimator sklearn classifier Yes Fitted or unfitted classifier
X array-like (n, 2) Yes Bivariate feature data
y array-like Yes Target class labels
features list of str No Feature names for axis labels
classes list of str No Human-readable class names
step_size float No Resolution of decision boundary mesh (default: 0.0025)

Outputs

Name Type Description
ax matplotlib.Axes Axes with decision boundary mesh and scatter plot

Usage Examples

from sklearn.svm import SVC
from sklearn.datasets import make_moons
from yellowbrick.contrib.classifier import DecisionViz

X, y = make_moons(n_samples=200, noise=0.2)

viz = DecisionViz(SVC(), features=["Feature 1", "Feature 2"], classes=["A", "B"])
viz.fit(X, y)
viz.show()
# Quick method
from yellowbrick.contrib.classifier import decisionviz

decisionviz(SVC(), X, y, features=["x1", "x2"], classes=["A", "B"])

Related Pages

Page Connections

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