Course contentsShow
← Machine Learning and Deep Learning
Lesson 443 of 3,53810. Feature EngineeringFree lesson

Aggregation and Window Features

Create features from grouped statistics and rolling window calculations across related data points.

Aggregation and Window Features

What you'll learn: How to create powerful features by summarizing groups of related data points and calculating statistics over sliding windows.

What Are Aggregation and Window Features?

Imagine you're analyzing customer purchase data. Instead of just looking at each transaction individually, you could ask: "What's the average purchase amount per customer?" or "How many purchases did this customer make in the last 30 days?" These summary statistics often reveal patterns that individual data points can't.

Aggregation features summarize data across groups. You group related records (like all transactions from the same customer) and compute statistics: sum, mean, count, max, min, or standard deviation.

Window features (also called rolling or moving features) calculate statistics over a sliding "window" of sequential data points. They're especially valuable for time series, where recent context matters—like tracking a stock's 7-day moving average or a user's activity in the past week.

When These Features Shine

  • Customer behavior: Average order value, total spending, days since last purchase
  • Time series: Rolling averages, cumulative sums, trends over recent periods
  • Click data: Number of clicks per session, average time between clicks
  • Sensor readings: Mean temperature over the last hour, maximum vibration in recent samples

These features capture context and relationships that raw values miss. A single purchase of 100meanslittlewithoutknowingthecustomertypicallyspends100 means little without knowing the customer typically spends 20—that's the power of aggregation.

The Core Idea

Group → Calculate → Create new feature. Whether you're grouping by customer ID, time window, or session, you're transforming multiple observations into meaningful summaries that your model can learn from.

Key Takeaway: Aggregation and window features transform raw data into context-rich summaries by computing statistics across groups or sliding time windows, capturing patterns that individual observations cannot reveal.