Function Basis Encoding of Numerical Features in Factorization Machines

Alex Shtoff, Elie Abboud, Rotem Stram, Oren Somekh

Abstract

Factorization machine (FM) variants are widely used for large scale real-time content recommendation systems, since they offer an excellent balance between model accuracy and low computational costs for training and inference. These systems are trained on tabular data with both numerical and categorical columns. Incorporating numerical columns poses a challenge, and they are typically incorporated using a scalar transformation or binning, which can be either learned or arbitrarily chosen. In this work, we provide a systematic and theoretically-justified way to incorporate numerical features into FM variants by encoding them into a vector of function values for a set of functions of one's choice.

We view FMs as approximators of segmentized functions, namely, functions from a field's value to the real numbers, assuming the remaining fields are assigned some given constants, which we refer to as the segment. From this perspective, we show that our technique yields a model that learns segmentized functions of the numerical feature spanned by the set of functions of one's choice, namely, the spanning coefficients vary between segments. Hence, to improve model accuracy we advocate the use of functions known to have powerful approximation capabilities, and offer the B-Spline basis due to its well-known approximation power, widespread availability in software libraries and its efficiency in terms of computational resources and memory usage. Our technique preserves fast training and inference, and requires only a small modification of the computational graph of an FM model. Therefore, incorporating it into an existing system to improve its performance is easy. Finally, we back our claims with a set of experiments that include a synthetic experiment, performance evaluation on several data-sets, and an A/B test on a real online advertising system which shows improved performance.

Introduction

Factorization Machines (FMs) are the backbone of modern recommendation systems, prized for their ability to handle high-dimensional sparse data with real-time efficiency. However, FMs face a persistent challenge with continuous numerical features. While categorical data is easily embedded, continuous variables like age or price are typically handled through simple scaling or binning. These traditional methods often fail to capture the complex, non-linear relationships inherent in real-world data.

The Approximation-Estimation Trap

In standard practice, numerical features are often discretized into bins. This approach introduces a fundamental "approximation-estimation" trade-off. If the number of bins is too small, the model becomes "blocky," resulting in poor approximation and missed nuances. Conversely, increasing the number of bins to capture more detail leads to sparsity; many bins will contain insufficient data points, making it impossible for the model to learn reliable representations. This leads to high-variance, noisy estimations.

The approximation-estimation trap: coarse binning (left) lacks resolution, while fine binning (right) suffers from sparsity-induced noise.

Proposed Method: Basis Function Encoding

To overcome these limitations, the authors propose Basis Function Encoding. Instead of mapping a numerical value to a single discrete bin, the value is mapped to a vector of values calculated from a set of continuous "basis functions."

B-Splines as the Optimal Basis

The researchers advocate for the use of B-Splines. Unlike global polynomials, B-Splines offer "local control," meaning that for any given input, only a few basis functions are non-zero. This property ensures computational efficiency—comparable to traditional binning—while enabling the model to learn smooth, continuous curves rather than jagged step functions.

The Segmentized View

Mathematically, this approach allows the FM to learn "segmentized" functions. This means the model can learn how a specific feature's impact varies across different segments of the data. For example, a user's sensitivity to "Price" might be represented as a smooth curve that takes a different shape for different demographic segments. By transforming the input into a basis vector, the FM essentially becomes a powerful non-linear function approximator.

Experimental Results

The researchers validated Basis Function Encoding across multiple benchmarks, including the Criteo advertising dataset and several public tabular datasets (e.g., California Housing, Higgs).

  • Sparsity Resilience: Synthetic experiments demonstrated that while binning performance collapses as the number of intervals increases due to sparsity, the spline-based model remains stable and accurate.
  • Performance Lift: On public datasets, the spline-based approach consistently outperformed binning, showing accuracy improvements ranging from 3.36% to 9.2%.
  • Real-World Impact: In a live A/B test on a major online advertising platform, the proposed model reduced Click-Through Rate (CTR) prediction error from 21% to 8%. This significant improvement led to the model's adoption into full production.

Conclusion

Basis Function Encoding, particularly using B-Splines, provides a theoretically justified and practically robust method for integrating numerical features into Factorization Machines. By replacing discrete bins with continuous basis representations, the method allows models to capture high-resolution details without falling into the sparsity trap. The approach is easy to implement in existing systems and offers a clear path to improving the accuracy of large-scale recommendation and advertising models.

Summary updated

BibTeX
@article{shtoff2024function,
  author = {Alex Shtoff and Elie Abboud and Rotem Stram and Oren Somekh},
  title = {{Function Basis Encoding of Numerical Features in Factorization Machines}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=M4222IBHsh},
}
Figure