0Pricing
Machine Learning Academy · Lesson

Visualising Data with Matplotlib and Seaborn

Learners will plot histograms, scatter plots, and correlation heat maps to explore data distributions and relationships before modelling.

Why Visualisation Matters in ML

Charts aren't just for reports — they're a diagnostic tool at every step. Matplotlib gives full control; Seaborn makes beautiful stats plots with less code.

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

# Set seaborn theme for all plots
sns.set_theme(style='whitegrid', palette='muted')

# Load a built-in dataset
df = sns.load_dataset('tips')
print(df.head())

Histograms: Understanding Distributions

A histogram bins a numeric column to show its shape — normal, skewed, or with outliers. Spotting skew tells you when a log transform might help your model.

import matplotlib.pyplot as plt
import seaborn as sns

df = sns.load_dataset('tips')

fig, axes = plt.subplots(1, 2, figsize=(12, 4))

# Raw distribution (right-skewed)
axes[0].hist(df['total_bill'], bins=30, edgecolor='white')
axes[0].set_title('Total Bill Distribution (Raw)')

# After log transform
import numpy as np
axes[1].hist(np.log(df['total_bill']), bins=30, edgecolor='white')
axes[1].set_title('Total Bill Distribution (Log Transformed)')

plt.tight_layout()
plt.show()

All lessons in this course

  1. Installing Anaconda and Jupyter Notebook
  2. NumPy Essentials: Arrays and Math Operations
  3. Pandas for Data Manipulation
  4. Visualising Data with Matplotlib and Seaborn
← Back to Machine Learning Academy