Data Visualization
Data visualization encodes data as charts, plots, and maps so patterns, outliers, and errors become visible, from dataset audits to training curves.
Data visualization is the graphical representation of data, which encodes values as position, length, color, or shape in charts, plots, maps, and annotated images so that people can see patterns, outliers, and errors that tables of numbers hide. Exploratory visualization helps an analyst understand data during exploratory data analysis, a practice John Tukey championed in his 1977 book of the same name, and explanatory visualization communicates a finding to others. In machine learning and computer vision, it is how practitioners audit datasets, follow training, diagnose model errors, and explain predictions.
Why Visualization Matters#
Statistician Francis Anscombe made the case in 1973 with four small datasets, now called Anscombe's quartet, that share nearly identical summary statistics:
import matplotlib.pyplot as plt
import numpy as np
# Anscombe's quartet: four datasets of 11 (x, y) points each
x = [10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5]
quartet = {
"I": (x, [8.04, 6.95, 7.58, 8.81, 8.33, 9.96, 7.24, 4.26, 10.84, 4.82, 5.68]),
"II": (x, [9.14, 8.14, 8.74, 8.77, 9.26, 8.10, 6.13, 3.10, 9.13, 7.26, 4.74]),
"III": (x, [7.46, 6.77, 12.74, 7.11, 7.81, 8.84, 6.08, 5.39, 8.15, 6.42, 5.73]),
"IV": ([8] * 7 + [19] + [8] * 3, [6.58, 5.76, 7.71, 8.84, 8.47, 7.04, 5.25, 12.50, 5.56, 7.91, 6.89]),
}
# Print each dataset's summary statistics and draw its scatter plot side by side
fig, axes = plt.subplots(1, 4, figsize=(12, 3), sharex=True, sharey=True)
for ax, (name, (xs, ys)) in zip(axes, quartet.items()):
r = np.corrcoef(xs, ys)[0, 1]
print(f"{name}: mean y {np.mean(ys):.2f}, variance y {np.var(ys, ddof=1):.2f}, correlation {r:.3f}")
ax.scatter(xs, ys)
ax.set_title(f"Dataset {name}")
fig.savefig("anscombe.png")All four datasets print a mean y of 7.50, a variance of 4.12 or 4.13, and a correlation of 0.816 or 0.817, yet the saved plots look nothing alike: dataset I is a noisy linear trend, II is a smooth curve, III is a perfect line with one outlier, and IV is a vertical stack of points whose correlation comes entirely from one far-off point. Researchers at Autodesk extended the idea in 2017 with the Datasaurus Dozen, thirteen datasets with the same statistics, one of which plots as a dinosaur.
Choosing a Chart#
A chart works when its encoding matches the question. Comparisons across categories suit bar charts, trends over time suit line charts, distributions suit histograms and box plots, relationships between two variables suit scatter plots, and spatial patterns suit maps and heatmaps. In their 1984 graphical perception experiments, William Cleveland and Robert McGill found that people judge position along a common scale most accurately, followed by length, angle, area, and finally color shading, which is why bar and dot charts beat pie charts for precise comparisons. Color carries categories and magnitudes best with perceptually uniform, colorblind-safe colormaps such as viridis, the default in Matplotlib since version 2.0.
Visualization in Machine Learning#
- Dataset bias audits: Class histograms expose imbalance, maps of box positions and sizes reveal objects that always appear in one region or at one scale, and image grids reveal label errors.
- Loss function curves: Training and validation loss plotted per epoch show convergence, and a validation loss that rises while training loss falls signals overfitting.
- Confusion matrices and precision-recall curves: Show which classes a model confuses and how precision trades against recall as the confidence threshold changes.
- Embedding maps with t-SNE: Projections such as t-SNE place similar samples near each other in two dimensions, exposing clusters, duplicates, and outliers.
- Saliency maps and prediction overlays: Draw boxes, masks, or keypoints on images and highlight the pixels that drove a decision.
Experiment trackers such as TensorBoard and Weights & Biases chart these metrics live across many training runs, so overfitting shows up as soon as validation loss turns upward. Ultralytics YOLO also saves the core plots to each training run's folder by default: labels.jpg shows class instance counts, a sample of box shapes, and 2D histograms of bounding box centers and of box widths versus heights, while results.png charts every loss and metric per epoch, and validation adds confusion matrices and precision-recall curves.
Data Visualization vs. Related Terms#
- Data analytics: The broader process of inspecting, cleaning, and modeling data to answer questions. Visualization is one of its main tools for exploration and for reporting results.
- Explainable AI (XAI): Explains why a model made a decision, and visualizations such as saliency maps are among its main outputs.
- Data mining: Uses algorithms to find patterns in large datasets automatically, and visualization often presents the patterns it finds.
- Dashboards: Collections of charts on one screen that track key metrics over time, common in business intelligence tools and in production model monitoring.










