Implementation:DistrictDataLabs Yellowbrick GridSearchColorPlot
| Knowledge Sources | |
|---|---|
| Domains | Model_Selection, Visualization |
| Last Updated | 2026-02-08 05:00 GMT |
Overview
Concrete tool for visualizing GridSearchCV results as a color-coded heatmap of scores across two hyperparameter dimensions.
Description
The GridSearchColorPlot renders the results of a scikit-learn GridSearchCV as a pcolormesh heatmap where the x and y axes represent two hyperparameters and the color represents the cross-validation score. It automatically projects results onto the specified parameter pair using the param_projection utility.
Usage
Import this visualizer when comparing the effect of two hyperparameters on model performance after a grid search.
Code Reference
Source Location
- Repository: DistrictDataLabs_Yellowbrick
- File: yellowbrick/gridsearch/pcolor.py
- Lines: 1-177
Signature
class GridSearchColorPlot(GridSearchVisualizer):
def __init__(
self, estimator, x_param, y_param,
metric="mean_test_score", colormap="RdBu_r", ax=None, **kwargs,
):
"""Grid search heatmap visualizer."""
def gridsearch_color_plot(
estimator, x_param, y_param, X=None, y=None, ax=None, **kwargs,
):
"""Quick method for grid search color plot."""
Import
from yellowbrick.gridsearch import GridSearchColorPlot
from yellowbrick.gridsearch.pcolor import gridsearch_color_plot
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| estimator | GridSearchCV | Yes | Fitted or unfitted grid search |
| x_param | str | Yes | First hyperparameter name |
| y_param | str | Yes | Second hyperparameter name |
| metric | str | No | Score metric (default: "mean_test_score") |
| colormap | str | No | Matplotlib colormap (default: "RdBu_r") |
Outputs
| Name | Type | Description |
|---|---|---|
| ax | matplotlib.Axes | Axes with color-coded heatmap |
Usage Examples
from sklearn.model_selection import GridSearchCV
from sklearn.svm import SVC
from yellowbrick.gridsearch import GridSearchColorPlot
grid = GridSearchCV(SVC(), {"C": [0.1, 1, 10], "gamma": [0.01, 0.1, 1]})
viz = GridSearchColorPlot(grid, "param_C", "param_gamma")
viz.fit(X, y)
viz.show()