# Feature Engineering

> Turning domain knowledge into informative inputs: aggregates, ratios, date parts, text counts, interactions and transformations. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/machine-learning/feature-engineering
Last updated: 2026-11-28

Turning domain knowledge into informative inputs: aggregates, ratios, date parts, text counts, interactions and transformations.

Intermediate · about 10 hours · difficulty 3/5

Learn first: [Data Cleaning and Missing Values](https://www.internhack.in/roadmaps/tracks/machine-learning/data-cleaning)

For tabular problems, good features beat fancy algorithms. Feature engineering encodes what you know about the domain in a form models can use.

### Common patterns

- **Datetime features**: hour, weekday, month, holidays, time since an event. Use cyclical sine/cosine encoding for hour or month when order wraps around.
- **Aggregates**: counts, means and recency per user, product or region (group-by features).
- **Ratios and differences**: price per square foot, debt to income.
- **Transformations**: `log1p` for heavy-tailed values, binning when relationships are step-like.
- **Interactions**: products of features for linear models; trees find many interactions on their own.
- **Text and geo basics**: word counts, TF-IDF, distances to landmarks.

### Process

Add features one idea at a time and measure the change in cross-validated score. Keep a log of what helped. Remove features that add noise or are expensive to compute in production.

### Pitfalls

Aggregates computed over the whole dataset (including the future or the test set) leak information. Features that are unavailable at prediction time are useless no matter how predictive they look offline.

**Good enough to move on** when you can add three to five engineered features to a baseline and demonstrate their value with cross-validation.

## Key concepts

- **Datetime and cyclical features**
- **Group-by aggregates**
- **Ratios and domain features**
- **Log and power transforms**
- **Interaction and polynomial features**
- **Feature selection**: Importance, RFE, mutual information
- **Automated feature tools**

## Mini project

On the Kaggle Bike Sharing Demand dataset, engineer datetime, weather and rolling features and report the cross-validated RMSE gain of each feature group over a baseline.

## Check yourself

Why might a feature that improves validation score still be a bad feature to ship?

## Free resources

- [Kaggle Learn: Feature Engineering](https://www.kaggle.com/learn/feature-engineering) (Kaggle)
- [scikit-learn: Feature selection](https://scikit-learn.org/stable/modules/feature_selection.html) (scikit-learn)

Previous: [Data Cleaning and Missing Values](https://www.internhack.in/roadmaps/tracks/machine-learning/data-cleaning) · Next: [Encoding Categories and Scaling Numbers](https://www.internhack.in/roadmaps/tracks/machine-learning/encoding-and-scaling)

## More in From Raw Data to Model-Ready Features

- [Exploratory Data Analysis](https://www.internhack.in/roadmaps/tracks/machine-learning/exploratory-data-analysis)
- [Data Cleaning and Missing Values](https://www.internhack.in/roadmaps/tracks/machine-learning/data-cleaning)
- [Feature Engineering](https://www.internhack.in/roadmaps/tracks/machine-learning/feature-engineering)
- [Encoding Categories and Scaling Numbers](https://www.internhack.in/roadmaps/tracks/machine-learning/encoding-and-scaling)
- [Train/Validation/Test Splits and Data Leakage](https://www.internhack.in/roadmaps/tracks/machine-learning/splits-and-leakage)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Machine Learning Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/machine-learning)
