Feature Engineering
Preparing data for better results
Preparing data for better results
Features are the inputs your model uses to make predictions. They are the characteristics or attributes of each data point. If you're predicting house prices, features might include the number of bedrooms, square footage, neighborhood, and year built.
Choosing and preparing the right features is called feature engineering, and it's often the most important step in any ML project.
If predicting house prices is the test, features are the study materials. Give the model the wrong study materials (like the color of the front door) and it won't learn anything useful. Give it the right ones (location, size, condition) and it will ace the test.
No algorithm, no matter how sophisticated, can overcome bad input data. If your features are noisy, irrelevant, or poorly formatted, your model's predictions will reflect that.
That's why data scientists often spend more time on feature engineering than on choosing or tuning algorithms.
Putting everything on the same scale. If salary ranges from $30K-$200K and age from 18-65, the model might think salary matters more just because the numbers are bigger. Normalization fixes this.
Turning categories into numbers the model can use. The color "red" becomes is_red=1, is_blue=0, is_green=0. Each category gets its own yes/no column.
Picking only the most useful features and dropping the rest. Too many features can confuse the model (the "curse of dimensionality") and slow things down.
Combining existing features into more useful ones. If you have house price and square footage, creating "price per square foot" gives the model a more directly useful signal.
Models work with numbers, not text. Here's how we convert a "color" feature:
| Color | is_red | is_blue | is_green |
|---|---|---|---|
| Red | 1 | 0 | 0 |
| Blue | 0 | 1 | 0 |
| Green | 0 | 0 | 1 |
Great feature engineering requires domain knowledge. A data scientist working on flight-delay predictions needs to know that weather, time of day, and airline hub status all matter, while seat color does not.
The right features matter more than the fanciest algorithm. A simple model with well-chosen features will often outperform a complex model with bad features. This is why domain expertise is so valuable in data science.