openskills.info
Open Course

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

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