---
name: Feature Engineering
description: Better features beat fancier models.
---
# Feature Engineering

The biggest model accuracy gains usually come from better features, not better algorithms. A simple model on well-engineered features routinely beats a complex model on raw data.

## Techniques
- **Encode domain knowledge.** "Days since last purchase" captures behavior raw timestamps can't. What does a domain expert mentally compute? Encode that.
- **Transform for linearity/scale.** Log-transform skewed monetary values; ratios instead of raw counts where the denominator matters.
- **Aggregate meaningfully.** Per-user averages, rolling windows, counts over periods. The grain of aggregation changes what the model can learn.
- **Handle categoricals deliberately.** One-hot for low cardinality; target/frequency encoding for high cardinality; never leak the target into the encoding.

## Avoid leakage
Never include a feature that wouldn't be available at prediction time. "Time since last purchase" is fine; "total purchases this month" leaks if the month isn't over at prediction.