Before any model training begins, data exploration โ genuinely looking at the data โ surfaces issues that would otherwise silently undermine everything built on top of it.
The Core Exploration Checklist
| Check | What It Reveals |
|---|---|
| Visualize a random sample of examples directly | Catches obviously wrong, corrupted, or mislabeled data early โ often the single most valuable exploration step |
| Check class balance | Severe imbalance changes evaluation metric choice (see the Evaluation Metrics category) and may require techniques like Focal Loss (see Focal Loss) |
| Check feature/input distributions | Reveals outliers, unexpected ranges, or scale mismatches needing preprocessing |
| Check for duplicate or near-duplicate examples | Duplicates spanning train/validation/test splits leak information and inflate apparent performance |
| Sanity-check label quality on a sample | Real datasets often contain some fraction of mislabeled examples โ knowing roughly how much helps set realistic performance expectations |
Code โ A Quick Exploration Pass
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv("labels.csv")
print(df['label'].value_counts()) # class balance check
print(df.isnull().sum()) # missing value check
# Visualize a random sample of actual images -- often catches problems no summary statistic would
fig, axes = plt.subplots(2, 4, figsize=(12, 6))
sample = df.sample(8)
for ax, (_, row) in zip(axes.flat, sample.iterrows()):
img = load_image(row['filename'])
ax.imshow(img)
ax.set_title(row['label'])
ax.axis('off')
Why This Step Is So Frequently Skipped, and Shouldn't Be
It's tempting to move straight to model building, especially with time pressure โ but issues caught here (a systematically mislabeled class, a data leak between splits, a severe class imbalance) are dramatically cheaper to fix at this stage than after weeks of modeling built on top of flawed data, where diagnosing the root cause of poor or misleading results becomes far harder.
Common Mistakes
- Relying purely on summary statistics without ever visually inspecting actual raw examples โ many real data quality issues (corrupted images, wrong labels, offensive content) are far easier to catch by eye than through any single aggregate statistic.
- Skipping data exploration under time pressure and discovering fundamental data problems only after significant modeling effort has already been invested.
Interview Relevance
Q: "Why is manually inspecting a random sample of actual data points, not just summary statistics, an important part of data exploration?" Aggregate statistics (class counts, means, distributions) can look completely normal while individual examples are corrupted, mislabeled, or otherwise problematic in ways no summary number would reveal. A direct, visual/manual inspection of actual samples frequently catches issues โ obviously wrong labels, corrupted files, unexpected content โ that would otherwise silently degrade model training and be difficult to diagnose later.
Practice Question
You discover during data exploration that 15% of images in your dataset appear to have incorrect labels. What are your options before proceeding to model training?