Feature engineering is the process of using knowledge of a problem to create, transform and select the input variables, called features, that a machine learning model learns from. Raw data rarely come in a form that algorithms use well. A timestamp is just a number until someone extracts the hour or the day of the week. A purchase history becomes useful when summarized as spending in the last thirty days. Practitioners often say that better features matter more than a fancier algorithm, and in work with tabular data, a large share of the effort in a machine learning project goes into this step. It is related to, but different from, feature extraction, which usually refers to automatically computing compact features from complex data such as images.
What is a feature?
A feature is a measurable property of an example that is used as an input to a model. In a house price model, features might include the floor area, the number of bedrooms and the neighborhood. The target, or label, is the sale price. The model learns how combinations of features relate to the target. The choice of features limits what the model can discover, because information that is not captured in any feature cannot be used.
Common feature engineering techniques
- Handling missing values: fill gaps with the median, the most frequent value or a model-based estimate, and often add an indicator feature showing that the value was missing, since missingness can be informative.
- Scaling and normalization: put numerical features on comparable ranges using standardization, which centers values and divides by the standard deviation, or min-max scaling. This matters for distance-based and gradient-based methods.
- Encoding categorical variables: convert categories to numbers using one-hot encoding, ordinal encoding or target encoding, which replaces a category by the average outcome for that category and must be done carefully to avoid leakage.
- Binning: group a continuous variable such as age into ranges.
- Transformations: apply logarithms, square roots or power transforms to reduce skew and tame outliers.
- Interaction and polynomial features: multiply or combine features, such as price per square foot, to capture relationships that a simple model cannot find by itself.
- Date and time features: extract day of week, month, holiday flags, and time since an event.
- Aggregations: summarize transactions or events per customer, such as counts, sums, averages and recency.
- Text and image features: turn text into word counts, TF-IDF scores or embeddings, and images into pixel statistics or learned embeddings.
Feature selection
More features are not always better. Irrelevant or redundant features add noise, slow training and increase the risk of overfitting. Feature selection keeps only the useful ones. Filter methods rank features by simple statistics, such as correlation with the target. Wrapper methods train models on different subsets and keep the best, as in recursive feature elimination. Embedded methods let the model choose, as when L1 regularization shrinks unimportant weights to zero or tree-based models report feature importance. Dimensionality reduction, such as principal component analysis, offers a related route by combining features into fewer new ones. See dimensionality reduction.
The feature engineering process
The work is iterative. Analysts begin by exploring the data and talking to domain experts to find what drives the outcome. They create candidate features, test each addition on validation data and keep what helps. They automate the final transformations in a pipeline, so that the same steps are applied during training and prediction. Many teams use feature stores, shared systems that save and serve features consistently across projects, to avoid mismatches between training and production.
Avoiding data leakage
A frequent and costly error is leakage, which happens when a feature includes information that will not be available at prediction time. For example, using the total number of calls a customer made in the month after a prediction date to predict churn would be illegitimate. Leakage can also happen by computing scaling statistics or target encodings on the full dataset before splitting into training and test sets. The remedy is to build features only from past information, to fit all transformations on the training data and to validate with time-aware splits when data come in time order.
Feature engineering in deep learning
Deep learning reduced the need for manual feature design for images, audio and text, because neural networks learn their own representations from raw input. Yet feature engineering remains important for tabular data, where gradient boosted trees often match or beat deep networks, and for combining sources, such as adding geographic or calendar information. Automated tools can generate and test features, such as Featuretools and automated machine learning platforms, but human insight about the domain still produces many of the best features.
Applications and examples
In credit scoring, features such as the ratio of debt to income, the number of late payments and the length of credit history drive predictions. In retail demand forecasting, holidays, promotions, weather and recent sales form key features. In fraud detection, features like the distance from a customer’s usual location and the speed of consecutive purchases help flag suspicious transactions. In predictive maintenance, rolling averages and trends of sensor readings signal wear before a machine fails.
Advantages and challenges
Good features raise accuracy, allow simpler models, make results easier to explain and can reduce the amount of data needed. The challenges are the time and expertise required, the risk of leakage and overfitting through endless trial and error and the burden of keeping feature pipelines consistent and documented. Features based on sensitive attributes or their proxies can also introduce unfairness, so teams review them for bias.
Best practices for feature engineering
Start simple and measure. Build a baseline with the raw features, add one group of engineered features at a time and keep only those that improve validation results. Document each feature with its meaning, source and formula so that others can reproduce and audit it. Wrap every step in a pipeline object, so that the same transformations run in training and in production. Watch for features that are unstable over time, such as counts that depend on how long a record has existed, and check that no feature quietly encodes a protected attribute.
Feature engineering checklist
Before finishing, confirm that every feature is available at prediction time, that transformations were fitted on training data only and that the feature list has been reviewed by someone who knows the domain.
FAQs
Is feature engineering still needed with deep learning? Less for images, text and audio, but it remains valuable for tabular data and for adding domain knowledge.
What is the difference between feature engineering and feature selection? Engineering creates or transforms features, and selection chooses which of them to keep.
What is one-hot encoding? It replaces a categorical variable with a set of binary columns, one for each category, with a one marking the category present.
More in Machine Learning
Key facts
- Feature engineering uses domain knowledge to turn raw data into features that make machine learning algorithms work better.1
- Common techniques include scaling, encoding categorical variables, binning, creating interaction terms and extracting date parts.2
- Features must be computed only from information available at prediction time, or the model suffers from data leakage.2
Related concepts
Quick checkWhy must features avoid data leakage?Show answer
Because using information that would not be available at prediction time makes test results look better than real performance and the model fails in use.
Sources
- Google, Machine Learning Crash Course: Working with numerical and categorical data, https://developers.google.com/machine-learning/crash-course
- scikit-learn, Preprocessing data, https://scikit-learn.org/stable/modules/preprocessing.html
- Zheng and Casari, Feature Engineering for Machine Learning, https://www.oreilly.com/library/view/feature-engineering-for/9781491953235/
Editorially reviewed by Specialty Digest Editorial TeamLast reviewed November 17, 2026Researched and drafted with AI assistanceReport an issue
