Feature engineering is the process of creating, selecting, and transforming input variables (features) to help a machine learning model learn more effectively. Raw data is often not in the best form for a model to use directly.
Raw features — House size, Bedrooms, Year built
Possible engineered features
Useful — Study hours, Previous exam scores, Attendance rate
Less useful — Student ID, Favorite color, Random noise
Raw feature — Year of birth: 1998
Engineered feature — Age: 2026 − 1998 = 28
Age is often more useful than birth year because the relationship between age and outcomes is usually more direct.
Original — House Size, Income, Age
Original — Color, Country, Product Category
Raw text — "This product is amazing!"
Engineered features
Medical imaging — May use texture analysis or edge detection to find patterns not visible from raw pixels alone
Time features help models learn patterns related to cycles and seasonality.
Raw — "123 Main Street, Toronto"
Study Hours × Attendance Rate → Combined Learning Effort
This can be more informative than either feature alone because both variables together describe effort better than either individually.
Price per square foot = price / house size
Clicks per visit = clicks / total visits
Revenue per customer = revenue / customers
House size: 1500 sq ft | Price: $300,000
Ratio: $300,000 / 1500 = $200 per sq ft
Binning groups continuous values into discrete categories. This can help when the relationship between a feature and the target is not linear.
Age — 0–17: Child, 18–64: Adult, 65+: Senior
Income — 0–30k: Low, 30k–80k: Middle, 80k+: High
Aggregated features provide context that individual records alone cannot.
Healthcare — BMI = weight / height², Blood pressure ratio, Symptom duration in days
Finance — Debt-to-income ratio, Loan-to-value ratio, Credit utilization rate
Education — Grade point average, Completion rate, Attempts per assignment
Feature 1 — Age, range 18–80
Feature 2 — Income, range 20,000–200,000
Without scaling the model may give more weight to income simply because its values are larger.
Fix — Apply normalization or standardization
Customer income missing
A missing indicator feature tells the model that the fact that a value is missing may itself carry information.
Predicting — Whether the student will pass the final exam
Leaked feature — "Final exam score" (this IS the thing you are predicting — it cannot be an input feature)
Including information that would not be available at prediction time is data leakage.
Training accuracy — Very high (e.g., 99%)
Test accuracy — Much lower (e.g., 72%)
Adding too many features can cause the model to memorize training data rather than learn patterns that generalize.
1. Location — Most important
2. House size — Very important
3. Number of bedrooms — Moderately important
4. Age of house — Less important
Raw — Square footage, year built, zip code
Engineered — Age of house, price-per-sqft, distance to city center
Raw — Grades, attendance
Engineered — Average score trend, improvement rate, subject difficulty score
Raw — User click history, product categories
Engineered — Click frequency, recency score, category preference ratio
| Feature Engineering | Feature Selection |
|---|---|
| Creates new features | Chooses from existing features |
| Transforms raw data | Removes redundant or unhelpful features |
| Requires domain knowledge | Can be automated (e.g., feature importance) |
| Happens before model training | Can happen before or after training |
Understand the problem and prediction target
Explore the raw data and understand each column
Identify relevant existing features
Create new features from existing ones
Apply transformations (log, sqrt, ratios, binning)
Encode categorical features
Scale numerical features
Remove redundant or low-value features
Check for data leakage
Evaluate model performance with engineered features
Ask the AI if you need help understanding how to create features, which transformations to apply, how to encode categories, or how to avoid common feature engineering mistakes.