Key takeaways
A better representation of business behaviour can be more useful than switching to a more complex model.
Create features using information that was genuinely available when the prediction would have been made.
Choose transformations that suit the model, the data and the business context; more features are not necessarily better.
Evaluate feature additions on unseen data and assess their contribution to business decisions, not just model scores.
Treat feature definitions, ownership, freshness and training-serving consistency as production requirements.
Before you replace the model, examine what it knows
Imagine a subscription business that wants to identify customers who may leave next month. Its data science team has tested several machine learning algorithms, yet the predictions remain disappointing. The company has years of billing records, customer interactions and service-usage data. Surely, there must be a better model?
Perhaps. But look at the information the current model receives. It knows how much each customer spends and how long they have been with the company. It does not know whether their usage has recently declined, whether payments have begun to fail or whether they have contacted support repeatedly about an unresolved issue.
These patterns are present in the business records, but they have not been expressed in a form the model can use easily. Machine learning feature engineering is the process of turning raw information into meaningful inputs that help a model recognise relevant patterns.
For business leaders, this distinction matters. Before approving another modelling project or investing in additional computing capacity, it is worth examining whether the existing model has access to the right information at the right time.
The difference between a data field and a useful signal
A feature is an input used by a machine learning model. It could be a numerical measurement, a category, a calculated value or a representation of more complex information such as text. Feature engineering involves constructing, transforming and organising these inputs to support a particular prediction.
A transaction amount tells you what happened on one occasion. A customer’s average transaction amount over the previous 90 days provides context. Comparing recent spending with that historical average may reveal a change in behaviour. These three values describe different aspects of the same underlying data.
Feature creation is not identical to data cleaning. Cleaning addresses unreliable or inconsistent records. Feature engineering gives the cleaned information a useful representation. Feature selection then decides which candidate inputs to retain, while feature extraction can compress or represent complex inputs in another form.
There is no single definition of a good feature that applies everywhere. A measurement that helps predict customer churn may be irrelevant to inventory forecasting. Start with the decision the organisation needs to make, the entity being assessed and the prediction horizon.
Turning everyday records into predictive features
Consider the hypothetical subscription company again. Its objective is to predict whether an active customer will cancel within the next 30 days, using only information available at the weekly scoring time. A useful starting point is to create features that describe changes in customer behaviour rather than simply record account characteristics.
Recency: Calculate the number of days since the last successful service interaction. Frequency: Count relevant events during a defined period, such as support requests in the previous 30 days. Monetary measures: Calculate spending or outstanding balances over an appropriate historical window.
Change and trend: Compare usage in the latest 30 days with the preceding 30 days. Relative decline may be more informative than absolute usage because customers have different normal levels of activity. Handle new customers and zero denominators explicitly rather than silently substituting arbitrary values.
Ratios and interactions: A failed-payment proportion can distinguish repeated payment difficulties from occasional failures in accounts with many transactions. Combining contract type with tenure may help certain models capture patterns that either variable alone represents poorly.
The same principles apply beyond retention. A manufacturer might calculate changes in equipment vibration relative to a normal operating range. A retailer could use historical demand, days since a promotion and available stock to support forecasting. Stockouts need special attention because observed sales may understate demand.
Every candidate feature is a hypothesis about what might matter. Its business interpretation is useful, but it still needs empirical testing.
Choose the right transformation for the right model
Feature engineering also makes inputs suitable for the mathematical assumptions of a model. The appropriate technique depends on the type of data and the algorithm being used. The scikit-learn preprocessing documentation provides a detailed reference for these choices.[1]
Numerical scaling | Standardisation centres values and expresses their spread relative to training-data variability. It can help distance-based algorithms and regularised linear models. Conventional decision-tree splits generally do not require it.
Categorical encoding | One-hot encoding represents unordered categories with indicator columns. It works well for manageable numbers of categories. High-cardinality variables, such as product codes, may require hashing, grouping, regularised target encoding or model-specific categorical handling.
Missing values | Imputation fills unavailable measurements using an appropriate rule, such as a training-set median. A separate missingness indicator may capture useful information, but a missing value must not automatically be interpreted as zero. Some models can handle missing values directly.
Skewed numerical values | A suitable logarithmic transformation can compress large positive values and make certain relationships easier to model. Check the permitted input range, treatment of zeros and whether unusual values represent genuine business events.
Dates and time | Extract meaningful characteristics such as day of the week, season or elapsed time. Cyclical encodings can represent the relationship between the end and beginning of a repeating period. Use calendar information available at the forecast origin.
Do not apply transformations indiscriminately. For example, assigning arbitrary integers to unordered categories can introduce a misleading order in some algorithms. Fitting a supervised target encoder without an appropriate out-of-fold or historical procedure can leak information from the outcome into the input.
The hidden danger of information from the future
Suppose the subscription company scores customers at 9 am on a Monday. A data scientist includes cancellation-processing status in the historical training table, without checking when that status was recorded. The resulting model looks remarkably accurate because the feature can reveal an event that happened after the prediction time.
This is target leakage: information about the outcome, or information unavailable at the intended prediction time, is allowed to influence the model. It creates an unrealistic impression of performance and may leave the business with a model that cannot reproduce its apparent success in production.
For every feature, distinguish when an event occurred from when its data became available. An invoice posted yesterday might not reach the analytics platform until tomorrow. A historical dataset assembled today can accidentally include late-arriving records that would not have been available at the time.
Point-in-time feature construction recreates the information available for each historical decision. Historical feature-store retrieval can help with temporal joins, but the team must also explicitly handle availability timestamps, late arrivals and revisions.[2]
Keep the training and test data separate. Learn imputation values, encodings, scaling parameters and feature selection only from the training portion of each evaluation fold. A pipeline can enforce these boundaries, but it cannot repair a source dataset that already contains future information.[3]
For time-dependent problems, evaluate on later periods than those used for training and allow for outcome maturation. Where repeated entities or overlapping observation windows could distort the estimate, design the split around the real deployment situation and prevent inappropriate overlap.
How to prove that a feature earns its place
Begin with a simple model and a small set of well-understood features. Add candidate feature groups and compare their performance on equivalent validation periods. Keep an untouched final test set for the chosen design. This approach makes it easier to distinguish useful information from complexity that simply fits historical noise.
An ablation study removes a feature or feature group and measures how the model performs without it. Permutation importance instead disrupts a feature in evaluation data and measures how much the fitted model’s predictive performance changes. Correlated features can substitute for one another, so low individual importance does not necessarily indicate that the information is useless.[4]
Consider a retention team that can contact only 1,000 customers each week. A model that ranks likely cancellations more effectively within those 1,000 places may be more useful than one that improves overall classification accuracy. Compare precision at the contact limit, recall, probability calibration and results for important customer segments.
Better ranking still does not prove that contacting customers will prevent cancellations. A controlled retention experiment can estimate the incremental impact of outreach, accounting for contact costs, incentives and customers who would have stayed without intervention.
Keep the feature if it provides sufficiently stable value to justify its computation, maintenance and governance costs. A feature that offers a small improvement during one test period but fails when a source system changes may be a poor operational investment.
A feature is only useful if production can reproduce it
A model developed in a notebook might calculate 30-day usage from a complete historical export. The production system may depend on a daily feed that is incomplete for several hours. If the training and live calculations differ, the model is operating on inputs that no longer mean the same thing.
Training-serving skew includes discrepancies between the way features are generated during development and live prediction. Reusing transformation logic, comparing historical and production values for identical inputs and monitoring data changes can help detect this problem.[5]
Document feature definitions, entity keys, calculation windows, units, source tables, permitted uses, freshness requirements and handling of missing values. Version the transformation logic alongside the model. Automated tests should cover empty histories, unseen categories, zero denominators, extreme values and delayed records.
A feature store can help teams register reusable feature definitions and retrieve historical or recent values for different models.[6] A retailer with a single overnight forecast may instead need only a reliable data pipeline and versioned transformation code. Choose the infrastructure according to reuse, scoring latency and operational needs.
Monitor missing-value rates, freshness, unexpected categories, distribution changes, join failures and differences between training and serving values. A shift in a feature is a reason to investigate, not automatically a reason to retrain. Check model performance once outcomes become available.
Which information should the model be allowed to use?
Not every predictive feature is appropriate for a business decision. A location-related attribute, for example, might correlate with sensitive personal characteristics. An apparently neutral variable can act as a proxy for information that should not influence a consequential decision.
Review the purpose, data permissions, privacy implications and potential discriminatory effects of proposed features. For high-impact use cases, examine performance and error patterns across relevant groups where lawful and appropriate. Removing a single sensitive attribute does not eliminate the possibility of unfair outcomes.
Maintain a traceable record of who approved the feature, why it is needed, where its data originates and how changes are reviewed. Access controls, appropriate retention and purpose limitations should apply to derived features as well as raw records.
For a business that already has predictive models but experiences unreliable results, a focused review of feature quality, data availability and decision economics can be a practical starting point before funding a major redesign. The goal is not the largest possible feature set. It is a dependable set of signals that supports better decisions at a sustainable cost.
References and further reading
[1] scikit-learn documentation. Preprocessing data: https://scikit-learn.org/stable/modules/preprocessing
[2] Feast project documentation. Point-in-time joins, including treatment of feature availability timestamps: https://github.com/feast-dev/feast/blob/master/docs/getting-started/concepts/point-in-time-joins.md
[3] scikit-learn documentation. Common pitfalls and recommended practices: https://scikit-learn.org/stable/common_pitfalls
[4] scikit-learn documentation. Permutation feature importance: https://scikit-learn.org/stable/modules/permutation_importance
[5] Google for Developers. Rules of Machine Learning: Best Practices for ML Engineering: https://developers.google.com/machine-learning/guides/rules-of-ml
[6] Feast documentation. Feature retrieval: https://docs.feast.dev/getting-started/concepts/feature-retrieval
Apply the approach
Illustrative subscription retention example: at a weekly scoring time, a company assesses an active customer’s likelihood of cancelling in the following 30 days. The customer used the service 20 times in the preceding 30-day period and 8 times in the most recent 30-day period, has three support requests in the most recent 30 days and had two failed attempts among five payment attempts in the same period. All values are hypothetical and assumed available before scoring; they are not model predictions or measured business results.
Calculated as (20 − 8) / 20 × 100. This measures the relative reduction in activity between two consecutive 30-day windows; it does not establish why the customer’s activity declined.
Count of distinct support requests in the last 30 days. The context, severity and resolution status of those requests may also be relevant.
Two failures divided by five payment attempts. A high proportion may signal payment friction, but five attempts provide limited evidence and the causes require investigation.
Put the approach into practice
- 01Define the prediction target, decision horizon, scoring time and operational capacity before constructing features.
- 02Catalogue source availability, business definitions, candidate feature hypotheses and approved data uses.
- 03Build point-in-time training data and a reproducible preprocessing pipeline; fit transformations within training folds.
- 04Compare feature groups against a simple baseline using realistic validation periods, task metrics and business constraints.
- 05Version approved features and monitor freshness, missingness, skew, model outcomes and the cost of maintaining them.
Frequently asked questions
What is machine learning feature engineering in simple terms?
It is the process of preparing and creating model inputs that describe useful patterns in raw data. For example, converting a customer’s transaction history into recent spending, payment frequency and changes in activity gives the model a representation of behaviour rather than a collection of isolated events.
Do deep learning models still need feature engineering?
Deep learning can learn representations of images, text and other inputs rather than relying entirely on manually designed features. However, choosing the relevant inputs, defining observation windows, preparing labels, handling missing information and preventing leakage remain important. Domain-specific structured features can also be useful alongside learned representations.
How many features should a machine learning model have?
There is no universal optimum. The appropriate number depends on available training data, model capacity, redundancy, stability, prediction latency and business requirements. Start with interpretable candidates, evaluate additions on representative unseen data and retain those that justify their operational cost.
Can automated feature engineering replace business expertise?
Automation can generate and test many candidate transformations, especially aggregations and interactions. It cannot independently establish whether a feature is available at decision time, permissible for the intended purpose or meaningful to the business. Human review and validation remain necessary.
Is a feature store necessary for every machine learning project?
No. Versioned data pipelines and shared transformation code can be sufficient for a small batch-scoring use case. A feature store becomes more attractive when several models need reusable definitions, reliable historical retrieval or low-latency feature access.