0–5 min
Real Hook
5–25 min
Core Concept
25–45 min
Live Coding
45–55 min
You Code It
55–60 min
Cheat Sheet
🔥 Real-World Hook (0–5 min)

NASA engineers had data showing O-ring failures at low temperatures before the Challenger disaster. The data existed — but it was in a table. When someone finally plotted failures vs. temperature the night before launch, the pattern was unmistakable. They didn't have time to act.

A good chart surfaces what tables hide. In ML, visualization catches distribution shifts, outliers, and class imbalance before they ruin your model.

📈 Core Chart Types (5–25 min)

ChartUse whenExample
plt.hist()See distribution shapeScore distribution
plt.scatter()Relationship between 2 variablesHeight vs weight
plt.bar()Compare categoriesSales by city
plt.plot()Trends over timeModel loss vs epoch
sns.heatmap()Correlation matrixFeature correlations
sns.boxplot()Distribution + outliersSalary by role

💻 Live Demo — AI Training Dashboard (25–45 min)

>import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd

# Simulate model training history
epochs = np.arange(1, 21)
train_loss = 1.0 * np.e ** (-0.15 * epochs) + np.random.normal(0, .02, 20)
val_loss   = 1.0 * np.e ** (-0.12 * epochs) + np.random.normal(0, .03, 20)

# 1. Training curves (most important AI chart)
plt.figure(figsize=(10, 4))

plt.subplot(1, 2, 1)
plt.plot(epochs, train_loss, label="Train Loss", color="#7c3aed")
plt.plot(epochs, val_loss,   label="Val Loss",   color="#f59e0b", linestyle="--")
plt.xlabel("Epoch"); plt.ylabel("Loss")
plt.title("Training Curves"); plt.legend()

# 2. Feature correlation heatmap
df = pd.DataFrame(np.random.randn(50, 4),
               columns=["age", "income", "score", "churn"])
plt.subplot(1, 2, 2)
sns.heatmap(df.corr(), annot=True, cmap="coolwarm", fmt=".2f")
plt.title("Feature Correlations")

plt.tight_layout()
plt.savefig("dashboard.png", dpi=150)
print("Saved dashboard.png")

📋 You Code It (45–55 min)

✍ Task

Plot a histogram of 500 random exam scores (normal distribution, mean=70, std=12). Add a vertical red line at mean. Title it "Score Distribution". Save as scores.png.

⚡ Day 4 Cheat Sheet

plt.figure(figsize=(w,h))
Set canvas size
plt.subplot(r, c, i)
Multi-chart layout
plt.hist(data, bins=20)
Histogram
plt.scatter(x, y)
Scatter plot
plt.axvline(x=mean)
Vertical reference line
sns.heatmap(df.corr())
Correlation heatmap
plt.savefig("out.png")
Save to file
plt.tight_layout()
Fix overlapping labels