Feature engineering
Feature engineering turns raw data into inputs that make a useful signal easier for a model to learn.
Tiny example
Section titled “Tiny example”Raw transaction records contain timestamps and amounts. A fraud model may benefit from derived features:
transactions in the last houramount ÷ the account's normal amountdays since the account was openedcountry changed since the previous transactionChanging random forest to a neural network cannot recover information that the inputs never represent.
Before changing the algorithm again
Section titled “Before changing the algorithm again”- Verify labels, missing values, class balance, and the evaluation split.
- Inspect errors by user, time period, and important segment.
- Add only features available at the real prediction time.
- Fit transformations on training data, then apply them to validation and test data.
- Compare against the same baseline and check latency, drift, fairness, and maintainability.
scikit-learn’s pipeline guidance warns that fitting preprocessing or feature selection on test data leaks information and creates an optimistic score.1
FDE note
Section titled “FDE note”Feature engineering is an experiment, not a guaranteed fix. Watch for label leakage, future information, unstable identifiers, and proxy variables that encode sensitive attributes.
Footnotes
Section titled “Footnotes”-
scikit-learn, common pitfalls, recommends splitting before preprocessing and fitting transformations only on training data. ↩