Course map
Stage 1: Foundations
Stage 2: Machine Learning
Stage 3: Deep Learning
Stage 4: LLMs & Generative AI
Stage 5: Production & Specialization

Part 03 / Topic 2 of 6

Exploring a dataset

Before modelling, answer four questions: how big, what types, what ranges, how balanced?

# examples/01_first_look_at_the_churn_dataset.py
from ailab import make_churn

df = make_churn()
print(df.shape)
print(df.head(3).to_string(index=False))
print()
print("missing values per column:")
print(df.isna().sum()[lambda s: s > 0])
print("churn rate:", round(df["churned"].mean(), 3))
(2000, 7)
 customer_id  tenure_months  monthly_charges  support_calls       contract  has_internet  churned
           1             23            96.41              2       one-year          True        0
           2             61            51.12              2 month-to-month          True        0
           3              3            20.00              0       two-year          True        1

missing values per column:
monthly_charges    46
dtype: int64
churn rate: 0.299

Three facts worth writing down: 2,000 rows; 46 missing monthly_charges; 29.9% churn. The class balance decides which metrics make sense later (Part 6), and the missing values need a plan (next section).

🧪 Quick quiz

  1. Which pandas call counts missing values per column?
Show the answer

df.isna().sum() — it showed 46 missing monthly_charges values out of 2,000 rows.

Done here? The practice set for Part 3 — 4 exercises with solutions — is on the part page.

Search the guide