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 MissingValuesBar

From Leeroopedia


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

Overview

Concrete tool for visualizing missing values per feature as a horizontal stacked bar chart, provided by the Yellowbrick contrib module.

Description

The MissingValuesBar renders a horizontal bar chart showing the count of missing (NaN) values for each feature in a dataset. When target labels are provided, bars are stacked by class to reveal whether missingness is associated with specific target values. It inherits from MissingDataVisualizer which handles feature name extraction.

Usage

Import this visualizer when performing initial data quality assessment to identify features with missing values and whether missingness patterns differ across target classes.

Code Reference

Source Location

Signature

class MissingValuesBar(MissingDataVisualizer):
    def __init__(self, width=0.5, color=None, colors=None, classes=None, **kwargs):
        """Missing values bar chart visualizer."""

def missing_bar(X, y=None, ax=None, classes=None, width=0.5, color="black", **kwargs):
    """Quick method for one-off missing values bar visualization."""

Import

from yellowbrick.contrib.missing import MissingValuesBar
from yellowbrick.contrib.missing.bar import missing_bar

I/O Contract

Inputs

Name Type Required Description
X array-like or DataFrame Yes Feature data with potential NaN values
y array-like No Target labels for stacked bars
classes list of str No Class names for legend
width float No Bar width (default: 0.5)

Outputs

Name Type Description
ax matplotlib.Axes Axes with horizontal bar chart

Usage Examples

import numpy as np
import pandas as pd
from yellowbrick.contrib.missing import MissingValuesBar

# Create data with missing values
df = pd.DataFrame({
    "A": [1, np.nan, 3, np.nan, 5],
    "B": [np.nan, 2, 3, 4, 5],
    "C": [1, 2, np.nan, 4, np.nan],
})

viz = MissingValuesBar()
viz.fit(df.values)
viz.show()

Related Pages

Page Connections

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