dholzmueller/pytabkit
ML models + benchmark for tabular data classification and regression
PyTabKit — What It Is
PyTabKit is a Python library for tabular machine learning (working with data in table form, like spreadsheets). It provides ready-to-use models for classification (predicting a category) and regression (predicting a number), plus code for benchmarking (fairly comparing) those models.
It was presented at NeurIPS 2024 and is accompanied by a paper.
Key Capabilities
- Scikit-learn interfaces: Models can be used like standard scikit-learn estimators — you call
fit()andpredict(). - Automatic GPU selection: If a GPU is available, it is used automatically.
- Automatic categorical column detection: When given a pandas DataFrame, it tries to identify categorical columns on its own.
- Built-in preprocessing: Numerical variables and regression targets are preprocessed automatically (no need to standardize manually).
- Early stopping: A training/validation split is used automatically to stop training at the right time.
- Cross-validation ensembling: Passing
n_cv=5trains an ensemble of models on 5-fold cross-validation (bagging). - Hyperparameter optimization: Some models support random search or tree-parzen-estimator (TPE) tuning.
- Post-hoc calibration: Temperature scaling and refinement stopping are available (from a separate paper on refining then calibrating).
Included Models
Models come in up to three variants: D (library defaults), TD (tuned defaults), and HPO (hyperparameter optimization). Some also support HPO-TPE or Ensemble (weighted ensembling).
- RealMLP — a neural network model with tuned defaults (TD, HPO, Ensemble)
- XGB, LGBM, CatBoost — interfaces to popular gradient-boosted tree libraries (D, TD, HPO, HPO-TPE)
- MLP, ResNet, FTT — models from the paper Revisiting Deep Learning Models for Tabular Data (D, HPO)
- MLP-PLR — MLP with numerical embeddings (D, HPO)
- TabR — a model combining tabular deep learning with nearest neighbors (D, HPO)
- TabM — a model using parameter-efficient ensembling (D, HPO)
- XRFM — a newer model (D, HPO)
- RealTabR — a TabR variant with default parameters (D)
- Ensemble-TD — a weighted ensemble of all TD models (RealMLP, XGB, LGBM, CatBoost)
Installation
pip install pytabkit[models]
- RealMLP and TabM work without the
[models]extra. - For xRFM on GPU, faster kernels are used if you install
kermac[cu12]orkermac[cu11](depending on your CUDA version). - TabR requires manually installing faiss (conda only).
- macOS note: LightGBM and XGBoost need OpenMP (
brew install libomp); mixing PyTorch-based models with LightGBM/XGBoost in the same process can crash due to conflicting OpenMP runtimes — installingpytorch,lightgbm, andxgboostfrom conda-forge avoids this. - Extra dependencies can be installed with
pytabkit[models,autogluon,extra,hpo,bench,dev]for additional models, AutoGluon integration, extra preprocessing, more HPO methods, benchmarking, and testing/documentation.
Basic Usage
from pytabkit import RealMLP_TD_Classifier
model = RealMLP_TD_Classifier() # or TabR_S_D_Classifier, CatBoost_TD_Classifier, etc.
model.fit(X_train, y_train)
model.predict(X_test)
You can configure many things through the constructor, for example:
from pytabkit import RealMLP_TD_Classifier
model = RealMLP_TD_Classifier(device='cpu', random_state=0, n_cv=1, n_refit=0,
n_epochs=256, batch_size=256, hidden_sizes=[256] * 3,
val_metric_name='cross_entropy',
use_ls=False, # for metrics like AUC / log-loss
lr=0.04, verbosity=2)
model.fit(X_train, y_train, X_val, y_val, cat_col_names=['Education'])
model.predict_proba(X_test)
Note: Missing numerical values are currently not allowed — they must be imputed beforehand.
Benchmarking Code
The repository includes code for:
- Dataset download
- Running methods in parallel on single-node, multi-node, and multi-GPU hardware, with automatic scheduling and RAM-constraint handling
- Analyzing and plotting results
It also contains wrappers for additional models like TabPFN, TabICL, and the KumoTabular foundation model.
A few-shot benchmark (new in v1.8.0) is included, from the TabICLv2 paper: datasets with 100–2000 samples where methods only get 16 training/validation samples.
Recommendations from the README
- For best possible results overall, the README recommends AutoGluon (which includes RealMLP and TabM in some configurations).
- For best results from pytabkit itself, use
Ensemble_HPO_Classifier(n_cv=8, use_full_caruana_ensembling=True, use_tabarena_spaces=True, n_hpo_steps=50)with aval_metric_namematching your target metric (e.g.,class_error,cross_entropy,brier,1-auc_ovr), or the correspondingRegressor. This can be slow to fit. - For a single model, use
RealMLP_HPO_Classifier(n_cv=8, hpo_space_name='tabarena-new', use_caruana_ensembling=True, n_hyperopt_steps=50). - For method evaluation, the README recommends TabArena instead of pytabkit's own benchmarking.
Notable Recent Changes (v1.8.0)
- Added a standalone, simplified RealMLP implementation (plain PyTorch, no Lightning) that additionally supports missing numerical values — marked experimental.
- Added the few-shot benchmark code.
- Added a wrapper for the KumoTabular foundation model.
- Bug fixes: CatBoost no longer crashes on single-class training sets or constant regression targets; fixed
batch_size='auto'in RealMLP; reduced log spam from PyTorch-Lightning. - Dropped Python 3.9 support; Python 3.13 is now tested.
Citation
If you use the repository for research, cite:
@inproceedings{holzmuller2024better,
title={Better by default: {S}trong pre-tuned {MLPs} and boosted trees on tabular data},
author={Holzm{"u}ller, David and Grinsztajn, Leo and Steinwart, Ingo},
booktitle = {Neural {Information} {Processing} {Systems}},
year={2024}
}
Contributors & Acknowledgements
Main developer: David Holzmüller, with contributions from Léo Grinsztajn, Ingo Steinwart, Katharina Strecker, Daniel Beaglehole, Lennart Purucker, and Jérôme Dockès. The code uses portions from other open-source projects (notably yandex-research/rtdl and catboost/benchmarks, both Apache 2.0 licensed).
Related
- Project
- Project
- Project
- Project