Tabular, time-series, scientific, and geometric deep learning · Tabular deep learning · SPE002 · Architecture
Feature Tokenizer Transformer (FT-Transformer)
FT-Transformer converts individual tabular features into tokens and models their interactions through transformer blocks.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page. The methods that run it are Experimental.
- FT-Transformer Experimental
Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.
- Availability
- Runs in CodeSplash (Experimental)
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through learn.ft_transformer. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
FT-Transformer converts individual tabular features into tokens and models their interactions through transformer blocks. It provides a strong structured neural baseline for classification or regression, particularly when compared under carefully matched tuning protocols.
Question / hypotheses
The operative question is whether the specified representation, symmetry, likelihood or physical constraint improves held-out behavior for this data domain. This is a learning framework, not a null-hypothesis test; losses, attention weights and predictive confidence are not statistical p-values.
Architecture / computational structure
Numeric columns receive feature-specific affine tokenization; categorical columns use embeddings. A classification token and transformer layers mix column tokens, and a head predicts the target. Column identity is retained by distinct tokenization parameters.
Assumptions
A table is not automatically a sequence with meaningful column order. Schema changes or category shifts can invalidate embeddings. Deep learning need not outperform boosted trees on every dataset; fair tuning and data leakage control are essential.
Formula / computational definition
Numeric feature becomes ; categorical feature becomes . Transformer output feeds . Fit cross-entropy or regression loss according to target type.
Parameters and notation
Learned or estimated: Feature tokenization vectors, categorical embeddings, attention/MLP/normalization parameters and the prediction head.
Hyperparameters and effects: Token width, attention heads, depth, dropout, weight decay, learning rate and preprocessing. Increasing width/depth raises capacity but may overfit small tables; categorical vocabulary and missing-value strategy are part of configuration.
Fitting, fine-tuning, and adaptation
Fit preprocessing inside each training fold, then optimize the task objective. For schema-compatible transfer, freeze the tokenizer/backbone while fitting a new head, then selectively unfreeze with a smaller learning rate. Newly introduced categories need explicit embeddings. Monitor validation loss, calibration and source-task retention rather than tuning on the final test set.
How to use and calibrate
Define the independent evaluation unit before preprocessing: row/entity, whole set/object, molecule/trajectory, input function or chronological forecasting origin. Keep target construction and normalization within permitted training data. Use entity/time-aware splits when needed, compare tree and MLP baselines, and report tuning budget, probability calibration, missingness robustness and performance by category frequency.
Example application
Model interactions among patient-independent laboratory covariates in a tabular classification study. This is a proposed use case, not a claim of validated performance on supplied real data.
Interpretation / pitfalls
Watch out
Assess model error against domain baselines and the stated assumptions. Component-level mathematical correctness does not establish paper reproduction or scientific validity. Use an independent validation design for model selection and a final held-out evaluation for claims; uncertainty and calibration require separate assessment.
Python and R code examples
Scope: Feature-specific numeric tokenization followed by one attention operation. Use the shared setup. Dependencies: NumPy / base R. Validation: Python executed; R unexecuted.
Full-model route: Python: authors’ tabular benchmark code or custom PyTorch. R: native torch tokenizers and transformer blocks, or bridge. The example isolates feature tokenization and attention with tiny fixed matrices.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Feature-specific numeric tokenization followed by one attention operation. Use the shared setup.
Shared setup for this chapter
import numpy as np
def sm(x):
x=np.asarray(x); e=np.exp(x-x.max(axis=-1,keepdims=True)); return e/e.sum(axis=-1,keepdims=True)
x=np.array([.4,1.2,-.5]); W=np.array([[.2,.5],[.7,-.1],[.3,.4]])
b=np.array([[.1,0.],[0.,.2],[.2,.1]])
tokens=x[:,None]*W+b
mixed=sm(tokens@tokens.T/np.sqrt(2))@tokens
print(tokens,mixed)
Component demo, not a trained model — Feature-specific numeric tokenization followed by one attention operation. Use the shared setup.
Shared setup for this chapter
sm <- function(x) {
if(is.null(dim(x))) { e<-exp(x-max(x)); return(e/sum(e)) }
t(apply(x,1,function(v) { e<-exp(v-max(v)); e/sum(e) }))
}
x<-c(.4,1.2,-.5); W<-matrix(c(.2,.5,.7,-.1,.3,.4),3,byrow=TRUE)
b<-matrix(c(.1,0,0,.2,.2,.1),3,byrow=TRUE)
tokens<-x*W+b; mixed<-sm(tokens%*%t(tokens)/sqrt(2))%*%tokens
print(list(tokens=tokens,mixed=mixed))
Sources
- Source 1arxiv.org
From the CodeSplash reference, entry SPE002.