Module 3: Feature Engineering
This module explores the transformation of raw data into features for machine learning. It covers multivariate regression with matrix notation, followed by key feature engineering techniques such as scaling, encoding, and selection.
Module 3: Feature Engineering — 1 hr 16 min
Six sections, one per learning objective. Every figure spoken in the lecture comes from a NumPy script with a fixed seed, so you can run it and reproduce each number.
- The design matrix 0:04
- What feature engineering is for 13:30
- Applying the transformations 25:12
- Encoding, and the ordering you did not intend 41:36
- Choosing what goes in 55:31
- Why more features hurt 1:07:27
Learning Objectives
- Define multivariate linear regression using matrix notation and compute predictions.
- Describe common feature engineering tasks (handling missing data and scaling features).
- Apply transformations such as log scaling, z-score normalization, and bucketing.
- Encode categorical variables and construct feature crosses.
- Evaluate features for inclusion in a model using selection strategies and discuss the curse of dimensionality.
The module in two minutes
An animated overview of the module’s through-line. Watch it before the lecture — it is the map, not the territory.
Lecture shorts
Short lectures and code walkthroughs from the instructor that reinforce this module. Some open partway into a longer video — that chapter is the part matched to this module.
Orientation audio
Why features decide projects, and the order to take the six parts in.
The through-line
Models see only the numbers you hand them. This module is about the gap between raw data and those numbers — the unglamorous work that decides more real-world projects than the choice of algorithm does.
It opens by generalizing regression to many inputs, in matrix form: X becomes a table, w a vector, prediction a product. That notation is not just compact — it is how every library expects your data, so learn to read shapes: rows are examples, columns are features.
Then the craft. Features on wildly different scales (income in dollars, age in years) tilt the loss surface so gradient descent zigzags; standardization levels it. Missing values must become numbers somehow — dropped, imputed, or flagged — and each choice encodes an assumption you should be able to defend. Categorical values become one-hot vectors, because handing "red=1, green=2, blue=3" to a linear model invents an ordering that does not exist.
The last two parts add expressive power without leaving the linear world. A feature cross multiplies two features so the model can respond to their combination — location and size, not location plus size. Bucketing turns a continuous value into ranges, letting a straight-line model fit a curve in steps.
The habit to build this week: when a model underperforms, look at the features before reaching for a fancier algorithm. Most of the fix is usually here.
The data is curved; the model is linear and stays linear. The only thing you control is which columns it sees. Toggle features and watch the same least-squares solver succeed or fail.
With x alone the best line misses the shape entirely. Add the x² column and the fit snaps in — no new algorithm, just a better table handed to the same solver. That is feature engineering: the model is only as expressive as the columns you build. (|x| gets partway there; sin 3x is a wrong guess and the solver correctly gives it little weight.)
Key concepts
- Multivariate Regression: Multiple input features
- Feature Scaling: Normalization, standardization
- Encoding: Converting categorical variables to numbers
- Feature Crosses: Combining features to capture interactions
- Curse of Dimensionality: Problems with high-dimensional data
The lecture notebook
Six parts, from scratch before any framework. Run every cell; change things and rerun — the notebook is the lecture.
In Colab: File → Save a copy in Drive keeps your work.
Exercise
Attempt the exercise before opening the solution — the attempt is where the learning happens.
Knowledge check
The quiz is self-graded and open-book. If a question surprises you, the corresponding lecture part is the fastest fix.
Reference and discussion
Finish the module
Complete the stages above, then claim the finish here.