Feature crossing

Also known as: feature crosses · cross features

On this page 7

Feature crossing is the technique of combining two or more input features into a synthetic feature whose value represents their joint occurrence, so that a model can learn an effect that neither feature carries on its own. In recommender systems, a cross such as user country by item language lets a ranking model learn that a Spanish-language video performs well for viewers in Mexico, even though country and language separately explain little.

The resulting features are called feature crosses or cross features. They are central to CTR prediction and multi-stage ranking, where most signals are sparse categorical identifiers. Crossing can be done manually through feature engineering or automatically inside architectures such as Wide & Deep, factorization machines and the Deep & Cross Network.

Why linear models need feature crosses

A linear model such as logistic regression assigns one weight to each feature and adds the contributions independently. It therefore cannot express that the combination of two values behaves differently from the sum of their parts. Crossing creates an explicit term for that combination, and the model learns a dedicated weight for each pair of values.

Formally, a cross of categorical features A and B produces a new feature whose categories are the Cartesian product of their values. With one-hot encoding, the crossed feature equals one only when both source values are present. For numeric features, the equivalent operation is a product term such as x1 times x2, the basis of polynomial regression.

FormConstructionTypical example
Categorical crossCartesian product of categoriesDevice type by app category
Bucketized numeric crossBins of numeric values crossedAge bucket by hour of day
Polynomial termProduct of numeric valuesPrice times discount rate
Hashed crossProduct mapped into fixed bucketsUser ID by item ID
Higher-order crossThree or more features combinedRegion by language by genre
Main forms of feature crossing

Crossing is often described as memorization: the model stores precise co-occurrence patterns seen in training. This is valuable for frequent pairs but offers no generalization to unseen pairs, because a crossed category that never appeared in training receives no learned weight.

Managing dimensionality and sparsity

The main cost of crossing is combinatorial growth. Crossing a feature with 10,000 values with another of 50,000 values yields up to 500 million possible categories, most of which are rare. This creates severe sparsity, large embedding tables and a high risk of overfitting on pairs observed only a few times.

Practitioners control this growth with a small set of well-known techniques, summarized in the table below.

TechniqueHow it worksTrade-off
Hashing trickMaps crossed values into fixed bucketsCollisions merge unrelated pairs
Frequency thresholdKeeps only pairs seen often enoughLoses rare but useful signals
BucketizationGroups numeric ranges before crossingCoarser resolution
RegularizationL1 or L2 penalties on cross weightsNeeds careful tuning
Embedding factorizationRepresents pairs through shared vectorsWeaker memorization of exact pairs
Techniques for keeping crossed features tractable

Hashing is the most common choice in production because it bounds memory regardless of vocabulary size. A practical rule is to set the number of hash buckets several times larger than the number of frequent pairs, which keeps the collision rate low enough to avoid noticeable accuracy loss.

Explicit and implicit crossing in neural models

Modern recommender architectures automate crossing so that engineers do not have to enumerate every useful pair. The key distinction is between explicit crossing, where the network computes product terms of bounded degree, and implicit crossing, where a deep multilayer perceptron is expected to discover interactions through nonlinear layers.

ModelCrossing mechanismInteraction order
Logistic regressionManual crosses onlyAs engineered
Factorization machineDot products of latent vectorsSecond order
Wide & DeepManual crosses in the wide partEngineered plus implicit
DeepFMFactorization layer beside a deep networkSecond order plus implicit
Deep & Cross NetworkStacked cross layersBounded, grows with depth
xDeepFMCompressed interaction networkExplicit vector-wise orders
How common ranking models handle feature interactions

Research has shown that plain multilayer perceptrons are inefficient at learning multiplicative interactions, even though they can approximate them in theory. This finding motivates explicit cross layers: in the Deep & Cross Network, each layer multiplies the original input with the current representation, so depth controls the polynomial degree with few extra parameters.

Choosing which features to cross

Good crosses come from domain hypotheses about joint effects. A cross is worth adding when the effect of one feature clearly depends on the value of another, for example when the appeal of a product category depends on season or when content language matters only together with user locale.

SituationRecommended approachReason
Strong known interactionAdd an explicit manual crossFast memorization of a reliable pattern
Many candidate pairsUse FM or cross network layersAvoids manual enumeration
Very high cardinality pairHash with frequency filteringKeeps memory bounded
Small training dataLimit crosses and regularizeReduces overfitting
Need for interpretabilityPrefer few named crossesWeights remain readable
Decision guide for manual crosses

Every candidate cross should be validated by offline evaluation, typically with AUC or log loss on a held-out time window, followed by an online experiment. Gains of a few tenths of a percent in AUC are considered meaningful at large scale, because ranking systems serve billions of predictions.

Common mistakes

  • Crossing everything: indiscriminate crosses inflate the model and dilute training signal across rare pairs.
  • Ignoring cold start: crosses with item IDs give no help for new items, so they must be paired with generalizing features.
  • Training and serving skew: crosses computed differently in offline pipelines and online services silently corrupt predictions.
  • Leaking the label: crossing with features derived from the outcome inflates offline metrics without real gains.

In plain words

Feature crossing means looking at two facts together instead of one at a time. Knowing that it is evening helps a little. Knowing that it is Friday helps a little. Knowing that it is Friday evening tells you much more about what someone wants to watch.

A recommendation model learns from such combinations. The combined fact becomes its own clue. The challenge is that there are many possible combinations, so engineers pick the useful ones or let the model find them.

A real-world example

A food delivery platform ranks restaurants with a gradient-boosted model followed by a neural ranker. Analysts notice that breakfast restaurants perform poorly overall yet receive many orders from office districts on weekday mornings. Neither cuisine type nor time of day captures this pattern alone.

The team adds a cross of cuisine type, hour bucket and neighborhood type, hashed into two million buckets with a minimum frequency of 50 orders. They also replace part of the deep network with three cross layers to capture further interactions automatically. Offline AUC rises by 0.4 percentage points on a held-out week.

In a two-week online test, weekday morning orders from office districts increase noticeably while other segments remain stable. The outcome confirms that one well-chosen cross can capture context that independent features miss.