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 GridSearchVisualizer

From Leeroopedia


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

Overview

Base class and utility function for visualizing scikit-learn GridSearchCV results as projected 2D views.

Description

The gridsearch.base module provides param_projection to project grid search cv_results onto two hyperparameter dimensions, extracting the best score at each grid point. The GridSearchVisualizer base class wraps a GridSearchCV estimator and provides the projection method along with a fit-and-draw pattern.

Usage

Subclass GridSearchVisualizer when building new grid search visualization types. Use param_projection directly for custom analysis of GridSearchCV results.

Code Reference

Source Location

Signature

def param_projection(cv_results, x_param, y_param, metric="mean_test_score"):
    """Projects grid search results onto 2 parameter dimensions."""

class GridSearchVisualizer(ModelVisualizer):
    def __init__(self, estimator, ax=None, **kwargs):
        """Base class for grid search visualizers."""

    def param_projection(self, x_param, y_param, metric): ...
    def fit(self, X, y=None, **kwargs): ...

Import

from yellowbrick.gridsearch.base import GridSearchVisualizer, param_projection

I/O Contract

Inputs (param_projection)

Name Type Required Description
cv_results dict Yes cv_results_ from GridSearchCV
x_param str Yes First parameter name
y_param str Yes Second parameter name
metric str No Score metric (default: "mean_test_score")

Outputs

Name Type Description
unique_x array Unique values of x parameter
unique_y array Unique values of y parameter
best_scores 2D array Best score at each (x, y) grid point

Usage Examples

from sklearn.model_selection import GridSearchCV
from sklearn.svm import SVC
from yellowbrick.gridsearch.base import param_projection

grid = GridSearchCV(SVC(), {"C": [0.1, 1, 10], "gamma": [0.01, 0.1, 1]})
grid.fit(X, y)

x_vals, y_vals, scores = param_projection(grid.cv_results_, "param_C", "param_gamma")

Related Pages

Page Connections

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