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 PrePredict

From Leeroopedia


Knowledge Sources
Domains Model_Evaluation, Utilities
Last Updated 2026-02-08 05:00 GMT

Overview

Passthrough estimator that wraps pre-computed predictions for use with Yellowbrick visualizers without re-running inference.

Description

The PrePredict class implements the scikit-learn estimator interface but returns pre-computed predictions instead of running a model. This is useful when model inference is expensive (e.g., deep learning models) and results have already been cached. It supports classification, regression, and clustering metrics via automatic estimator type detection.

Usage

Import PrePredict when you have pre-computed model predictions and want to use Yellowbrick visualizers without re-running inference. Wrap the predictions in a PrePredict object and pass it as the estimator to any Yellowbrick visualizer.

Code Reference

Source Location

Signature

class PrePredict(BaseEstimator):
    def __init__(self, data, estimator_type=None):
        """Passthrough estimator for pre-computed predictions.

        Parameters
        ----------
        data : array-like, callable, or path
            Pre-computed predictions, a callable returning them, or a file path.
        estimator_type : str, optional
            One of "classifier", "regressor", or "clusterer".
        """

    def fit(self, X, y=None): ...
    def predict(self, X): ...
    def score(self, X, y=None): ...

Import

from yellowbrick.contrib.prepredict import PrePredict

I/O Contract

Inputs

Name Type Required Description
data array-like, callable, or path Yes Pre-computed predictions
estimator_type str No "classifier", "regressor", or "clusterer"

Outputs

Name Type Description
predict() array-like Returns the pre-computed data
score() float Metric score (accuracy, R2, or silhouette)

Usage Examples

import numpy as np
from yellowbrick.contrib.prepredict import PrePredict
from yellowbrick.classifier import ClassificationReport

# Pre-computed predictions
y_pred = np.array([0, 1, 1, 0, 1, 0, 0, 1])
y_true = np.array([0, 1, 0, 0, 1, 1, 0, 1])

model = PrePredict(y_pred, estimator_type="classifier")
viz = ClassificationReport(model)
viz.score(None, y_true)
viz.show()

Related Pages

Page Connections

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