Yellowbrick Documentation

repository·develop·Indexed 26 days ago

https://github.com/districtdatalabs/yellowbrick

A suite of visual diagnostic tools (Visualizers) that extend the scikit-learn API to facilitate machine learning model selection through visual analysis. Yellowbrick provides visualizers for classification, clustering, feature visualization, model selection, regression, target visualization, and text visualization to help diagnose issues such as model complexity, bias, and class imbalance.

Tokens
54.4K
Snippets
145
Records
239
Agent score
86%

What's inside Yellowbrick

  1. Overview of Yellowbrick Visualizers

    develop

    Yellowbrick is a suite of visual analysis and diagnostic tools for scikit-learn. It introduces the Visualizer API, where visualizers act as scikit-learn estimators that learn from data to create visual representations of the model selection workflow.

    Visualizers can function in two primary ways:

    1. As Transformers: Visualizing the data space.
    2. As Model Wrappers: Wrapping a model estimator (similar to scikit-learn's ModelCV methods like RidgeCV or LassoCV) to visualize model performance and selection.

    Use visualizers to diagnose issues like model complexity, bias, heteroscedasticity, underfitting, overtraining, and class imbalance.

  2. Navigate Yellowbrick visualizer categories

    develop

    Yellowbrick visualizers are categorized by the type of analysis they perform. Use these categories to find the appropriate tool for your workflow:

    • Data Visualizers: Visualize instances relative to the model space (found in Feature analysis, Regression, Classification, and Clustering libraries).
    • Score Visualizers: Visualize model performance.
    • Model Selection Visualizers: Compare multiple model forms against each other.
    • Application Specific Visualizers: Specialized tools for specific tasks (e.g., Text analysis).
    • Utilities: Includes styles, best fit lines, and Anscombe's visualization.
  3. Visualize regression model performance

    develop

    Yellowbrick provides several visualizers to evaluate regression models by plotting instances in model space. Available regression evaluations include:

    • Residuals Plot: Plots the difference between the expected and actual values.
    • Prediction Error Plot (peplot): Plots the expected vs. actual values in model space.
    • Alpha Selection: Provides visual tuning of regularization hyperparameters.
    • Influence Plot: Visualizes the influence of individual data points.
  4. Use text-specific visualizers from yellowbrick.text

    develop

    The yellowbrick.text module provides visualizers designed for corpora rather than simple numeric arrays. These visualizers handle text-specific analysis such as word dispersion, document similarity, and part-of-speech distribution.

    Available text-specific visualizers include:

    • FreqDistVisualizer: Plots the frequency of tokens in a corpus.
    • TSNEVisualizer: Uses t-SNE to plot similar documents closer together for cluster discovery.
    • UMAPVisualizer: Uses UMAP to plot similar documents closer together for cluster discovery.
    • DispersionPlot: Plots the dispersion of target words throughout a corpus.
    • WordCorrelationPlot: Plots the correlation between target words across documents.
    • PosTagVisualizer: Plots the counts of different parts-of-speech in a tagged corpus.
    from yellowbrick.text import FreqDistVisualizer
    from yellowbrick.text import TSNEVisualizer
    from yellowbrick.text import UMAPVisualizer
    from yellowbrick.text import DispersionPlot
    from yellowbrick.text import WordCorrelationPlot
    from yellowbrick.text import PosTagVisualizer
    
    from sklearn.feature_extraction.text import TfidfVectorizer
    from sklearn.feature_extraction.text import CountVectorizer
  5. Understand the Yellowbrick Visualizer API

    develop
    Yellowbrick extends the scikit-learn API by introducing a core object called the Visualizer. These Visualizer objects allow models to be fit and transformed as part of a standard scikit-learn pipeline. They provide visual diagnostics throughout the transformation of high-dimensional data, helping to evaluate model performance, stability, and predictive value.
  6. License and usage terms for Yellowbrick

    develop

    Yellowbrick is licensed under the Apache 2.0 license. You are permitted to use the software for commercial purposes, modify the source code, and distribute it.

    Requirements for redistribution:

    • Include the original copyright and LICENSE.txt found in the root of the repository.
    • If a NOTICE file exists in the project, you must include it in your source distribution.
    • You may not use the names, trademarks, or logos of Yellowbrick contributors to promote your own work, except to reference the project itself.

    Yellowbrick is provided with no warranty.

  7. Understand the Yellowbrick Visualizer concept

    develop
    Yellowbrick extends the scikit-learn concept of an Estimator (an object that learns from data) by introducing the Visualizer. A Visualizer is an object that both learns from data and visualizes the results by wrapping Matplotlib procedures to produce rich visual analytics and publication-ready figures.
  8. Use yellowbrick.model_selection for model selection and tuning

    develop
    The yellowbrick.model_selection package provides visualizers to inspect the performance of cross-validation and hyperparameter tuning. These visualizers wrap sklearn.model_selection functionality or build upon it to perform multi-model comparisons, helping you find the optimal combination of features, algorithms, and hyperparameters.
  9. Visualize and evaluate clustering models with yellowbrick.cluster

    develop

    The yellowbrick.cluster module provides visualizers to evaluate unsupervised clustering algorithms, specifically focusing on centroidal mechanisms like K-Means. Because clustering models are difficult to score directly, Yellowbrick visualizers wrap scikit-learn clusterer estimators.

    To use a visualizer:

    1. Initialize the visualizer with a scikit-learn estimator.
    2. Call the visualizer's .fit() method with your data.
    3. Call .show() to display the clustering evaluation metric.

    Available visualizers include:

    • Elbow Method: Visualizes clusters according to a scoring function to help find the optimal $K$ parameter by looking for an "elbow" in the curve.
    • Silhouette Score: Visualizes the silhouette scores of each cluster within a single model.
    • ICDM (Inter-Cluster Distance Map): Visualizes the relative distance and size of clusters.
  10. Visualize missing values using MissingValues visualizers

    develop

    Yellowbrick provides MissingValues visualizers to identify locations of missing values (numpy NaN) within a dataset. There are two primary types of visualizers available:

    1. MissingValuesBar: Visualizes the total count of missing values for each feature.
    2. MissingValuesDispersion: Visualizes the distribution/position of missing values relative to the dataset index.
  11. Explore Yellowbrick Visualizer Gallery by Category

    develop

    Yellowbrick provides a wide range of visualizers categorized by machine learning task. You can use these visualizers to analyze features, evaluate models, or inspect datasets. The available categories include:

    • Feature Analysis: Tools for dimensionality reduction and feature relationships (e.g., RadViz, ParallelCoordinates, PCAProjection, ManifoldVisualization).
    • Regression Visualizers: Tools for evaluating regression models (e.g., ResidualsPlot, PredictionErrorPlot, AlphaSelection).
    • Classification Visualizers: Tools for evaluating classifiers (e.g., ClassificationReport, ConfusionMatrix, ROC AUC Curves, Precision-Recall Curves).
    • Clustering Visualizers: Tools for evaluating clustering performance (e.g., ElbowMethod, SilhouetteVisualizer, InterclusterDistanceMaps).
    • Model Selection Visualizers: Tools for hyperparameter tuning and model comparison (e.g., ValidationCurve, LearningCurve, CrossValidationScores, FeatureImportances).
    • Text Modeling Visualizers: Tools for NLP and text analysis (e.g., TokenFrequencyDistribution, TSNE Corpus Visualization, DispersionPlot).
    • Target Visualizers: Tools for inspecting target variable distributions and correlations (e.g., BalancedBinning, ClassBalance, PearsonCorrelation).