Tabular Data: Gradient Boosting vs Deep Learning
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
Most business data is tabular: rows are entities, columns are heterogeneous features (counts, amounts, categories, flags, dates) with no spatial or sequential structure to exploit. For this kind of data the practical default has been, for years, gradient-boosted decision trees (GBDT), not deep learning. This page explains why, what the evidence says and where it stops holding, then compares the four libraries you will meet: XGBoost, LightGBM, CatBoost and scikit-learn’s HistGradientBoosting. It assumes the idea of boosting from Histogram Gradient Boosting and the family map in Classic ML Algorithms at a Glance.
Versions at the check date of 2026-10-30: Python 3.13, scikit-learn 1.9, XGBoost 3.4 (3.4.1 on PyPI), LightGBM 4.7 (4.7.0), CatBoost 1.2 (1.2.10), PyTorch 2.15. Examples were run on Python 3.13 with scikit-learn 1.9.1, XGBoost 3.4.1, LightGBM 4.7.0, CatBoost 1.2.10 and PyTorch 2.15 (CPU) on 2026-11-01.
How gradient boosting works, in brief
Boosting builds an additive model \(F_M(x) = F_0 + \eta\sum_{m=1}^{M} h_m(x)\), where each new tree \(h_m\) is fitted to the negative gradient of the loss with respect to the current predictions (the pseudo-residuals) and the learning rate \(\eta\) shrinks every step. Modern implementations use a second-order Taylor expansion of the loss (gradient and Hessian) to pick splits and leaf values, regularize leaf weights with an L2 penalty, build histograms of binned feature values to find split points quickly, and handle missing values by learning a default direction per split. The result is a model that is accurate, invariant to monotone transformations of each feature, tolerant of missing values and mixed feature types, and fast to fit on millions of rows.
Why trees tend to win on tables
Grinsztajn, Oyallon and Varoquaux ("Why do tree-based models still outperform deep learning on typical tabular data?", NeurIPS 2022 Datasets and Benchmarks) benchmarked tree ensembles against neural networks on a curated set of medium-sized datasets (training sets of about ten thousand samples) and found that tree-based models stayed ahead even after extensive hyperparameter search, with the gap larger when the cost of tuning is counted. They attribute it to inductive biases that match typical tables:
-
Neural networks are biased toward smooth functions. Tabular targets are often irregular (thresholds, step changes, rules such as "age over 65"), which trees represent directly.
-
Uninformative features hurt neural networks more. Trees ignore useless columns when choosing splits; a network must learn to suppress them, and removing uninformative features narrows the gap.
-
Tables are not rotation invariant. Columns have individual meaning (age, price, country code), while an MLP’s first layer mixes them and is effectively rotation invariant; mixing features destroys information that axis-aligned splits keep.
Related studies reach compatible conclusions. Shwartz-Ziv and Armon ("Tabular Data: Deep Learning is Not All You Need", Information Fusion 2022) found that XGBoost matched or beat recent tabular networks on the datasets those papers had used and needed far less tuning, with an ensemble of networks and XGBoost doing best. McElfresh et al. ("When Do Neural Nets Outperform Boosted Trees on Tabular Data?", NeurIPS 2023) evaluated many algorithms and datasets and reported that the difference between top methods is often small, that light tuning of a GBDT can beat heavy tuning of a network, and that neural networks tend to do relatively better on small datasets, on very large ones, or on data with specific structure.
Where deep learning is competitive
The evidence supports a default, not a law. Consider neural approaches when:
-
the table is only one input among images, text, audio or graph structure, so a single network can be trained end to end (see Embeddings & Representation Learning);
-
the dataset is very large and you need online or incremental training, multi-task outputs or learned embeddings for high-cardinality categories (user and item identifiers);
-
you can pre-train or transfer from related tables (see Transfer Learning, Fine-Tuning & Foundation Models);
-
you want a differentiable component inside a larger system.
Research architectures for tables include FT-Transformer (feature tokenization plus a transformer), ResNet-style MLPs with careful numerical embeddings (Gorishniy et al., 2021 and later), TabM and others. Their benchmarks show they can match or occasionally beat GBDTs when well tuned, but at higher training cost. TabPFN is a different idea: a transformer pre-trained on a very large number of synthetic tabular tasks that predicts for a new small dataset in a single forward pass, without gradient descent on your data. Its published results (the Nature 2025 paper on TabPFN v2) target small datasets, in the order of thousands of rows, where it was reported to outperform tuned GBDTs; check the current limits in its documentation before using it, because they change between versions. Treat all such claims as hypotheses to verify on your own data with the same validation protocol for both families.
Comparing the libraries
All four implement the same boosting recipe with histogram-based split finding, so with equal care they usually land within a small margin of each other. The differences are in defaults, features and operational behaviour.
| Aspect | scikit-learn HistGradientBoosting* |
XGBoost | LightGBM | CatBoost |
|---|---|---|---|---|
Package |
|
|
|
|
Tree growth |
Leaf-wise, bounded by |
Level-wise ( |
Leaf-wise; |
Symmetric (oblivious) trees by default; depth-wise and loss-guided policies also exist |
Categorical features |
Native, up to 255 categories per feature ( |
Native with |
Native; pandas |
Native through ordered target statistics, |
Missing values |
Native |
Native, learns default direction |
Native |
Native, handled by a configurable mode |
GPU |
No |
Yes, |
Yes, build and device parameters |
Yes, |
Early stopping |
|
|
|
|
Monotonic constraints |
Yes |
Yes |
Yes |
Yes |
Strengths |
Zero extra dependency, consistent scikit-learn API, good defaults |
Mature, broad deployment support, many objectives, distributed training |
Very fast on large data, memory efficient |
Strong defaults, best categorical handling, less tuning |
Typical trade-off |
No GPU, fewer features |
More hyperparameters |
Leaf-wise trees can overfit small data without |
Slower on CPU for large data, larger model files |
The table reflects the documentation of each project at the check date; defaults change between releases, so confirm them for the version you install. Choose by constraint rather than by leaderboard: use HistGradientBoosting when you cannot add dependencies, XGBoost or LightGBM when you need GPUs, very large data or a particular objective, and CatBoost when high-cardinality categorical features dominate and you want robust defaults.
scikit-learn HistGradientBoosting
The scikit-learn estimator is a pragmatic first model: it needs no extra install, accepts NaN, supports monotonic and interaction constraints, and plugs into pipelines, cross-validation and the scikit-learn tooling. A complete regression example with early stopping:
from sklearn.datasets import fetch_california_housing
from sklearn.ensemble import HistGradientBoostingRegressor
from sklearn.metrics import root_mean_squared_error
from sklearn.model_selection import train_test_split
X, y = fetch_california_housing(return_X_y=True, as_frame=True)
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.2, random_state=0)
model = HistGradientBoostingRegressor(
max_iter=1000,
learning_rate=0.05,
early_stopping=True,
n_iter_no_change=20,
random_state=0,
).fit(X_tr, y_tr)
print("trees used:", model.n_iter_)
print("test RMSE:", round(root_mean_squared_error(y_te, model.predict(X_te)), 3))
Output:
trees used: 489 test RMSE: 0.443
The target is median house value in units of 100,000 dollars, so the typical error is about 44,000 dollars. root_mean_squared_error exists since scikit-learn 1.4; older tutorials use mean_squared_error(..., squared=False), which was deprecated and later removed. Source: scikit-learn user guide: Histogram-Based Gradient Boosting. The estimator’s parameters (monotonic constraints, interaction constraints, quantile loss, sample weights) are covered in Histogram Gradient Boosting.
XGBoost
XGBoost ("eXtreme Gradient Boosting") offers a scikit-learn-compatible API (XGBClassifier, XGBRegressor, XGBRanker) over its native Booster/DMatrix interface. The hist tree method is the default in the 2.x and 3.x series, and device="cuda" moves training to an NVIDIA GPU. Early stopping is configured in the constructor, and the validation data is passed to fit through eval_set.
import xgboost as xgb
from sklearn.datasets import fetch_california_housing
from sklearn.metrics import root_mean_squared_error
from sklearn.model_selection import train_test_split
X, y = fetch_california_housing(return_X_y=True, as_frame=True)
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.2, random_state=0)
X_tr, X_va, y_tr, y_va = train_test_split(X_tr, y_tr, test_size=0.2, random_state=0)
model = xgb.XGBRegressor(
n_estimators=5000,
learning_rate=0.05,
max_depth=6,
min_child_weight=1,
subsample=0.8,
colsample_bytree=0.8,
reg_lambda=1.0,
tree_method="hist",
device="cpu", # "cuda" for an NVIDIA GPU
early_stopping_rounds=50,
eval_metric="rmse",
random_state=0,
)
model.fit(X_tr, y_tr, eval_set=[(X_va, y_va)], verbose=False)
print("best iteration:", model.best_iteration)
print("test RMSE:", round(root_mean_squared_error(y_te, model.predict(X_te)), 3))
For categorical columns, give pandas category dtype and set enable_categorical=True; XGBoost then partitions categories natively and no one-hot encoding is needed. Keep the validation split separate from the test split, as above. Key parameters, in the order they usually matter: learning_rate with n_estimators (lower rate, more trees, early stopping chooses the count), max_depth or the leaf-wise policy, min_child_weight, subsample and colsample_bytree for row and column sampling, and the regularizers reg_lambda, reg_alpha and gamma (minimum loss reduction per split). Source: XGBoost documentation: Using the Scikit-Learn estimator interface and XGBoost Parameters.
LightGBM
LightGBM grows trees leaf-wise: it always splits the leaf with the largest loss reduction, which reaches a lower loss than level-wise growth for the same number of leaves but can overfit small datasets, so num_leaves and min_child_samples are the parameters to control first. It speeds up training with histogram binning, gradient-based one-side sampling (GOSS) and exclusive feature bundling (EFB). The project’s repository now lives at github.com/lightgbm-org/LightGBM; the PyPI package name is unchanged. Early stopping is a callback in the scikit-learn API.
import lightgbm as lgb
from sklearn.datasets import fetch_california_housing
from sklearn.metrics import root_mean_squared_error
from sklearn.model_selection import train_test_split
X, y = fetch_california_housing(return_X_y=True, as_frame=True)
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.2, random_state=0)
X_tr, X_va, y_tr, y_va = train_test_split(X_tr, y_tr, test_size=0.2, random_state=0)
model = lgb.LGBMRegressor(
n_estimators=5000,
learning_rate=0.03,
num_leaves=31,
min_child_samples=20,
subsample=0.8,
subsample_freq=1, # row subsampling is ignored unless this is above 0
colsample_bytree=0.8,
reg_lambda=1.0,
random_state=0,
verbosity=-1,
)
model.fit(
X_tr, y_tr,
eval_X=X_va, # LightGBM 4.7+; older releases use eval_set=[(X_va, y_va)]
eval_y=y_va,
eval_metric="rmse",
callbacks=[lgb.early_stopping(stopping_rounds=100), lgb.log_evaluation(period=0)],
)
print("best iteration:", model.best_iteration_)
print("test RMSE:", round(root_mean_squared_error(y_te, model.predict(X_te)), 3))
Categorical columns of pandas category dtype are detected by default (categorical_feature="auto"); the native API also accepts integer-encoded columns named in categorical_feature. LightGBM’s categorical splits can overfit categories with few samples, so keep min_data_per_group, cat_smooth and max_cat_threshold in mind for high-cardinality columns. Older code passes early_stopping_rounds= or verbose= directly to fit; these arguments were removed from the Python API in LightGBM 4.0 in favour of the callbacks shown above, and LightGBM 4.7 deprecated eval_set in favour of the eval_X and eval_y arguments. Source: LightGBM documentation: Python-package introduction and LightGBM Parameters Tuning.
CatBoost
CatBoost’s two distinguishing ideas address target leakage in categorical encoding. Ordered target statistics encode a categorical value by the mean target of the rows that came before it in a random permutation, so a row’s own label never contributes to its own feature. Ordered boosting applies the same discipline to the boosting residuals to reduce prediction shift. Its default trees are symmetric (oblivious): all nodes at one depth share the same split, which makes inference very fast and acts as regularization. Categorical columns are declared with cat_features, either on the estimator or on a Pool.
The following example, run for this page, compares CatBoost with scikit-learn’s HistGradientBoostingRegressor on a synthetic frame with one categorical column whose levels shift the price per square metre.
import numpy as np
import pandas as pd
from catboost import CatBoostRegressor, Pool
from sklearn.ensemble import HistGradientBoostingRegressor
from sklearn.metrics import root_mean_squared_error
from sklearn.model_selection import train_test_split
rng = np.random.default_rng(0)
n = 4000
df = pd.DataFrame({
"city": rng.choice(["Madrid", "Lyon", "Turin", "Porto", "Graz"], size=n),
"rooms": rng.integers(1, 7, size=n),
"area": rng.normal(80, 25, size=n).clip(20),
})
price_per_m2 = {"Madrid": 3.0, "Lyon": 2.5, "Turin": 2.2, "Porto": 2.0, "Graz": 1.8}
y = df["city"].map(price_per_m2) * df["area"] + 15 * df["rooms"] + rng.normal(scale=20, size=n)
X_tr, X_te, y_tr, y_te = train_test_split(df, y, test_size=0.25, random_state=0)
X_tr, X_va, y_tr, y_va = train_test_split(X_tr, y_tr, test_size=0.2, random_state=0)
hgb = HistGradientBoostingRegressor(
categorical_features="from_dtype", early_stopping=True, random_state=0
).fit(X_tr.astype({"city": "category"}), y_tr)
pred = hgb.predict(X_te.astype({"city": "category"}))
print("HistGradientBoosting RMSE:", round(root_mean_squared_error(y_te, pred), 2))
cb = CatBoostRegressor(
iterations=1000, learning_rate=0.1, depth=6, loss_function="RMSE",
random_seed=0, verbose=False, allow_writing_files=False,
)
cb.fit(
Pool(X_tr, y_tr, cat_features=["city"]),
eval_set=Pool(X_va, y_va, cat_features=["city"]),
early_stopping_rounds=50,
)
pred = cb.predict(Pool(X_te, cat_features=["city"]))
print("CatBoost RMSE:", round(root_mean_squared_error(y_te, pred), 2),
"best iteration:", cb.get_best_iteration())
Output:
HistGradientBoosting RMSE: 21.33 CatBoost RMSE: 20.86 best iteration: 67
The irreducible noise in this data has standard deviation 20, so both models are close to the best achievable error and the 0.5 difference is not meaningful; the example demonstrates the API, not a ranking. CatBoost writes training logs to a catboost_info directory by default, which allow_writing_files=False disables. By default fit keeps the best iteration when an eval_set is given (use_best_model), so the model is truncated at the best iteration. Source: CatBoost documentation: Python package quick start and CatBoost documentation: Transforming categorical features to numerical features.
Handling features for boosted trees
-
Do not one-hot encode high-cardinality categories for the libraries above; use their native categorical support. For plain scikit-learn estimators, see Categorical Encoding.
-
Do not scale or normalize. Trees depend only on feature order. Scaling is harmless and unnecessary, and only matters for the neural baseline below.
-
Leave missing values as NaN rather than imputing, unless you have a domain reason; the trees learn which side to send them.
-
Engineered features still pay off: ratios, differences, group aggregates (mean target by group, computed out-of-fold), date parts and lagged values. Boosted trees approximate such interactions poorly because every split is axis-aligned. See Feature Engineering.
-
Target encoding by hand leaks the label unless computed out-of-fold; prefer the library’s native handling or scikit-learn’s
TargetEncoder, which applies cross-fitting insidefit_transform. -
Trees cannot extrapolate. Predictions outside the training range are constant; for trending targets detrend or use a linear base model and fit boosting on the residuals.
Tuning
Boosting libraries are forgiving; a sensible order is:
-
Fix a small learning rate (0.03 to 0.1) and let early stopping choose the number of trees on a validation split or inside cross-validation.
-
Tune tree complexity: depth or leaves, and minimum samples per leaf (
min_child_weight,min_child_samples,min_samples_leaf). -
Tune sampling (
subsample,colsample_bytree) and regularization (reg_lambda,reg_alpha). -
Lower the learning rate at the end and refit for a small last gain.
Random or Bayesian search beats grids for this many parameters. Optuna is a common choice; note that its scikit-learn-style OptunaSearchCV lives in the separate optuna-integration package (from optuna_integration import OptunaSearchCV), not in optuna.integration as older tutorials show. Evaluate with a metric matching the business decision and keep a test set for the final number; see Grid, Randomized & Halving Search and Model Evaluation & Validation. Reproducibility depends on the thread count and on GPU nondeterminism; fix seeds and compare scores across seeds rather than expecting bit-identical runs.
A fair neural baseline in PyTorch
If you compare with deep learning, give the network a fair chance: standardized numerical inputs, a validation set for early stopping, AdamW with weight decay, dropout and a modest architecture. The following PyTorch 2.15 example trains an MLP on the California housing data. A neural network needs the validation split for early stopping, and it must remember the best weights, as discussed in Generalization, Bias–Variance & Regularization.
import copy
import numpy as np
import torch
from sklearn.datasets import fetch_california_housing
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from torch import nn
from torch.utils.data import DataLoader, TensorDataset
torch.manual_seed(0)
device = torch.accelerator.current_accelerator() or torch.device("cpu")
X, y = fetch_california_housing(return_X_y=True)
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.2, random_state=0)
X_tr, X_va, y_tr, y_va = train_test_split(X_tr, y_tr, test_size=0.2, random_state=0)
scaler = StandardScaler().fit(X_tr) # fitted on the training part only
def to_tensor(a):
return torch.tensor(np.asarray(a), dtype=torch.float32)
Xt, Xv, Xe = (to_tensor(scaler.transform(a)).to(device) for a in (X_tr, X_va, X_te))
yt, yv, ye = (to_tensor(a).unsqueeze(1).to(device) for a in (y_tr, y_va, y_te))
model = nn.Sequential(
nn.Linear(Xt.shape[1], 256), nn.ReLU(), nn.Dropout(0.1),
nn.Linear(256, 256), nn.ReLU(), nn.Dropout(0.1),
nn.Linear(256, 1),
).to(device)
optimizer = torch.optim.AdamW(model.parameters(), lr=1e-3, weight_decay=1e-4)
loss_fn = nn.MSELoss()
loader = DataLoader(TensorDataset(Xt, yt), batch_size=256, shuffle=True)
best_val, best_state, patience, bad_epochs = float("inf"), None, 15, 0
for epoch in range(300):
model.train()
for xb, yb in loader:
optimizer.zero_grad()
loss_fn(model(xb), yb).backward()
optimizer.step()
model.eval()
with torch.no_grad():
val_loss = loss_fn(model(Xv), yv).item()
if val_loss < best_val - 1e-4:
best_val, best_state, bad_epochs = val_loss, copy.deepcopy(model.state_dict()), 0
else:
bad_epochs += 1
if bad_epochs >= patience:
break
model.load_state_dict(best_state)
model.eval()
with torch.no_grad():
rmse = loss_fn(model(Xe), ye).sqrt().item()
print(f"stopped at epoch {epoch}, test RMSE {rmse:.3f}")
Source: PyTorch tutorials: Optimizing model parameters and PyTorch documentation: torch.optim.AdamW. On data like this a tuned GBDT typically matches or beats such a network at a fraction of the tuning effort, and the combination (averaging the predictions of both) often beats either one. Skewed numerical features benefit from a quantile or power transform before the network, which trees do not need. For high-cardinality categories give the network learned embeddings (nn.Embedding) instead of one-hot vectors; see Embeddings & Representation Learning.
Interpretation, calibration and deployment
-
Interpretation: tree ensembles support impurity-based and permutation importance, partial dependence and SHAP values (
TreeExplaineris exact and fast for trees). Impurity importance is biased toward high-cardinality features; prefer permutation importance or SHAP, and see Model Inspection. A fuller treatment is in Interpretability & Explainability. -
Calibration: boosted-tree probabilities with log loss are usually reasonable but not guaranteed to be calibrated, particularly after class weighting; check with Probability Calibration.
-
Deployment: each library saves its own format (XGBoost JSON or UBJSON, LightGBM text, CatBoost
.cbm) that is portable across versions better than pickles; scikit-learn models follow Model Persistence. ONNX conversion exists for the libraries through their converters, but keep the opset within what your target ONNX Runtime supports (see ONNX & Model Interoperability). Serving options are in Deploying & Serving ML Models.
Pitfalls
-
Early stopping on the test set. Use a validation split, not the final test set, and report the test score once.
-
Using the same rows for early stopping and for the final unbiased estimate in cross-validation; use nested validation or hold out an outer test fold.
-
Leaving the learning rate at a large value and capping
n_estimatorslow: the model underfits and tuning the other parameters cannot compensate. -
Leaf-wise growth (LightGBM,
HistGradientBoosting) on tiny datasets with an unconstrainednum_leavesormax_leaf_nodes. -
Treating label-encoded integers as ordered numbers for nominal categories in libraries without native categorical support.
-
Comparing a lightly tuned neural network with a defaults-only GBDT, or vice versa. Give both the same tuning budget and the same validation protocol.
-
Expecting identical results on CPU and GPU, or across thread counts.
-
Copying old code that relies on removed APIs:
early_stopping_rounds=andverbose=in LightGBM’sfit, thexgboostgpu_histandgpu_idparameters (replaced bydevice="cuda"),mean_squared_error(..., squared=False), andoptuna.integration.OptunaSearchCV.