Feature Engineering
Feature engineering is the process of transforming raw data into inputs that machine learning models can use effectively. It includes selecting relevant variables, creating new ones from existing data, handling missing values, and encoding non-numeric information so algorithms can learn patterns that lead to accurate predictions.
itArtificial intelligence and machine learning | OpenSkills.info
Intro
Feature Engineering
Feature engineering is the work of turning raw data into variables that a machine learning model can learn from. A model sees numbers in a matrix. Your job is to make those numbers carry the right information about the problem you want to solve.
The quality of features often matters more than the choice of algorithm. A simple model on well-crafted features routinely outperforms a complex model on raw, unprocessed data.
Why feature engineering matters
Machine learning algorithms find patterns in numeric representations. Raw data rarely arrives in a form that directly maps to the patterns you care about. Dates are timestamps, not "day of week" or "months since last purchase." Text is characters, not topic indicators. Addresses are strings, not distances to a warehouse.
Feature engineering bridges that gap. You apply domain knowledge to express what matters about the data in terms the algorithm can exploit.
The feature engineering workflow
raw data
-> understand the domain and the prediction target
-> explore distributions, relationships, missing patterns
-> transform: scale, encode, extract, combine
-> select: remove noise, redundancy, irrelevance
-> validate: does the feature improve model performance?
This workflow is iterative. You propose features, test them against a holdout set, keep what helps, and discard what adds noise or causes leakage.
Core techniques
Handling missing data
Missing values are information. A value can be missing at random, missing because of a system failure, or missing because it does not apply. Each case calls for a different strategy.
- Imputation fills gaps with a statistical summary (mean, median, mode) or a model-based estimate (KNN imputation, iterative imputation).
- Indicator features add a binary column marking whether the original value was missing. This preserves the signal that missingness itself carries.
- Dropping removes rows or columns when the proportion of missing data is too high to impute reliably.
Numeric transformations
- Scaling brings features to a common range. StandardScaler centers on mean zero with unit variance. MinMaxScaler maps to a fixed interval. Algorithms that use distances (KNN, SVM) or gradients (neural networks) are sensitive to scale differences.
- Log and power transforms reduce skewness in distributions with long tails, making linear models more effective.
- Binning converts continuous values into discrete intervals when the relationship to the target is non-linear or when you want to reduce noise.
- Interaction features multiply or combine existing features to capture relationships that a linear model cannot represent alone.
Encoding categorical variables
- One-hot encoding creates a binary column for each category. Use it when categories have no natural order and cardinality is manageable.
- Ordinal encoding assigns integers to ordered categories (low, medium, high).
- Target encoding replaces categories with the mean target value for that category. It handles high cardinality well but risks leakage if not computed within cross-validation folds.
- Frequency encoding replaces categories with their occurrence count or proportion.
Text features
- Bag of words and TF-IDF represent documents as sparse numeric vectors based on word frequency.
- Embeddings (Word2Vec, sentence transformers) produce dense vectors that capture semantic similarity.
- Extracted patterns use regex or NLP to pull structure: entity counts, sentiment scores, text length.
Date and time features
Extract components that carry predictive signal: hour, day of week, month, quarter, year. Compute durations: days since an event, time until a deadline. Flag business days versus weekends, holidays versus working days.
Aggregation features
When data has a group structure (transactions per customer, events per session), aggregate within groups: counts, sums, means, min, max, standard deviation, recency. These roll-up features summarize behavior at the granularity your model expects.
Feature selection
Not every feature helps. Irrelevant or redundant features add noise, increase training time, and can cause overfitting.
- Filter methods rank features by statistical relationship to the target (correlation, mutual information, chi-squared test) without training a model.
- Wrapper methods train models on subsets of features and evaluate performance (recursive feature elimination, forward/backward selection).
- Embedded methods perform selection as part of model training (L1 regularization, tree-based importance scores).
Data leakage
Leakage happens when information from outside the training window contaminates features. A feature built from future data or from the target itself produces artificially high performance that disappears at deployment.
Common sources:
- Aggregating over the entire dataset instead of only past data.
- Using target-encoded values computed on the full dataset rather than within CV folds.
- Including identifiers that correlate with the target by coincidence.
Guard against leakage by computing all transformations inside cross-validation splits and by reasoning about what information would be available at prediction time.
Feature stores
A feature store is infrastructure that manages the lifecycle of features: computation, versioning, storage, serving, and monitoring. It decouples feature logic from model training code and ensures that the same feature definitions used in training are used in production inference.
Feature stores solve the training-serving skew problem — when features computed offline during training differ from features computed online during serving.
Automated feature engineering
Tools like Featuretools and domain-specific AutoML systems generate candidate features automatically by applying predefined transformations and aggregations. Automation is useful for exploration, but the best features usually come from understanding the domain well enough to encode the right abstractions.
When feature engineering matters most
- Tabular data with domain structure — transactions, sensor readings, user behavior logs. This is where handcrafted features dominate.
- Classical ML algorithms (linear models, tree ensembles, SVMs) — these depend heavily on input representation.
- Small datasets — good features compensate for limited training examples.
Deep learning on images, audio, or long text sequences learns representations internally, reducing (but not eliminating) the need for manual feature engineering. You still choose input resolution, windowing, and augmentation — which are forms of feature engineering at a different abstraction level.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://scikit-learn.org/stable/modules/preprocessing.html
Supports
- StandardScaler, MinMaxScaler, RobustScaler behavior
- One-hot, ordinal, and target encoding
- Log and power transforms for skew reduction
- Binning and discretization
- Scaling importance for distance-based and gradient-based models
- https://scikit-learn.org/stable/modules/feature_extraction.html
Supports
- Bag of words, TF-IDF, hashing vectorizer
- Distinction between feature extraction and feature selection
- Text and image feature extraction methods
- https://scikit-learn.org/stable/modules/impute.html
Supports
- SimpleImputer strategies (mean, median, most_frequent)
- KNNImputer and IterativeImputer
- Missing indicator features
- Imputation within pipelines
- https://scikit-learn.org/stable/modules/feature_selection.html
Supports
- Variance threshold
- Univariate selection (mutual information, chi-squared)
- Recursive feature elimination
- Model-based selection (L1 regularization, tree importance)
- https://scikit-learn.org/stable/modules/cross_validation.html
Supports
- Fitting transforms within CV folds to prevent leakage
- Train/test split methodology
- Data leakage through improper preprocessing
- https://scikit-learn.org/stable/modules/compose.html
Supports
- Pipeline construction for reproducible preprocessing
- ColumnTransformer for heterogeneous data types
- Preventing leakage through pipeline encapsulation
- https://developers.google.com/machine-learning/data-prep
Supports
- Feature crosses and interaction features
- Embeddings for categorical data
- Data cleaning at scale
- Production-oriented feature engineering
- https://www.featurestore.org/
Supports
- Feature store architecture and concepts
- Training-serving skew prevention
- Feature lifecycle management
- https://dl.acm.org/doi/10.1145/1097658.1097801
Supports
- The 1971 SMART retrieval system and weighted term representations in the Timeline artifact.
- https://cdn.aaai.org/AAAI/1992/AAAI92-020.pdf
Supports
- The Relief feature-weighting method in the Timeline artifact.
- https://link.springer.com/article/10.1023/A:1012487302797
Supports
- Support vector machine recursive feature elimination in the Timeline artifact.
- https://www.jmlr.org/papers/v3/guyon03a.html
Supports
- The 2003 variable and feature selection survey in the Timeline artifact.
- https://jmlr.csail.mit.edu/papers/v12/pedregosa11a.html
Supports
- The scikit-learn publication and reusable machine learning workflow tooling in the Timeline artifact.
- https://ieeexplore.ieee.org/document/7344858
Supports
- Deep Feature Synthesis and relational automatic feature construction in the Timeline artifact.
- https://www.uber.com/gb/en/blog/michelangelo-machine-learning-platform/
Supports
- Uber Michelangelo and its centralized Feature Store in the Timeline artifact.
- https://cloud.google.com/blog/products/ai-machine-learning/introducing-feast-an-open-source-feature-store-for-machine-learning
Supports
- The Feast open-source release in the Timeline artifact.
- https://docs.feast.dev/master
Supports
- Feast offline and online stores, feature definitions, and feature serving for the Landscape artifact.
- https://docs.tecton.ai/
Supports
- Tecton batch, stream, and real-time feature definitions and inference access for the Landscape artifact.
- https://docs.hopsworks.ai/latest/concepts/fs/
Supports
- Hopsworks feature groups, feature views, point-in-time joins, and online and offline access for the Landscape artifact.
- https://www.hopsworks.ai/pricing
Supports
- Hopsworks free and paid service options used for the Landscape pricing classification.
- https://docs.databricks.com/aws/en/machine-learning/feature-store/
Supports
- Databricks feature tables, Unity Catalog governance and lineage, and feature lookup for the Landscape artifact.
- https://docs.aws.amazon.com/sagemaker/latest/dg/feature-store.html
Supports
- Amazon SageMaker Feature Store feature groups, online and offline stores, event-time history, and feature processing for the Landscape artifact.
- https://aws.amazon.com/sagemaker/ai/pricing/
Supports
- Amazon SageMaker Feature Store usage charges used for the Landscape pricing classification.
- https://learn.microsoft.com/en-us/azure/machine-learning/concept-what-is-managed-feature-store?view=azureml-api-2
Supports
- Azure managed feature-store transformation specifications, materialization, point-in-time joins, versioning, and sharing for the Landscape artifact.
