anwarrohmadi2006/nanoTabPFN-plus

Enhanced reimplementation of TabPFN with TabPFN-3 features: Randomized Feature Tokens, NaN handling, regression, ensembling, KV caching, synthetic prior training, and more.

Python

0

2 commits

updated May 19, 2026

See the code

README

nanoTabPFN-plus πŸš€

Enhanced reimplementation of TabPFN β€” upgraded from nanoTabPFN toward TabPFN-3.0 parity.

License: Apache 2.0 Python 3.10+ PyTorch

What is this?

nanoTabPFN-plus adalah reimplementasi edukatif dan fungsional TabPFN yang mengintegrasikan semua fitur utama TabPFN-3:

FeaturenanoTabPFN (original)nanoTabPFN-plus
Randomized Feature Tokensβœ—βœ…
NaN / Missing value handlingβœ—βœ…
Regression supportβœ—βœ…
Many-class (>10 classes)βœ—βœ…
Ensembling (n=32+)βœ—βœ…
KV Caching (faster inference)βœ—βœ…
Row chunking (scalable to 1M rows)βœ—βœ…
Temperature calibrationβœ—βœ…
Feature subsampling (high-dim)βœ—βœ…
DAG-aware synthetic priorBasicβœ… SCM-based
Multi-task loss (classification + regression)βœ—βœ…

Architecture

Input (X_train, y_train, X_test)
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   RandomizedFeatureTokenEncoder β”‚  ← NaN handling + per-feature tokens
β”‚   AdvancedTargetEncoder         β”‚  ← multi-class + regression + unknown token
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   CachedTransformerLayer Γ— N    β”‚  ← dual attention (row↔col) + KV cache
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   MultiTaskDecoder              β”‚  ← classification / regression / calibration
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
Predictions (probs / mean+std)

Quick Start

pip install torch numpy scikit-learn networkx
from model import NanoTabPFNPlusModel
from inference import TabPFN3Classifier
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split

# Load data
X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5)

# Create model
model = NanoTabPFNPlusModel(
    embedding_size=128,
    num_attention_heads=4,
    mlp_hidden_size=256,
    num_layers=4,
    num_outputs=10,
    max_features=500
)

# Create classifier with ensembling
classifier = TabPFN3Classifier(model, device='cpu', n_ensemble=8)
classifier.fit(X_train, y_train)
probs = classifier.predict_proba(X_test)
preds = probs.argmax(axis=1)

Training with Synthetic Prior

from prior import SyntheticTabularPrior
from train import train

prior = SyntheticTabularPrior(
    max_rows=1000,
    max_cols=100,
    num_classes=10,
    missing_rate=0.1,
    nonlinear_prob=0.5
)

model, history = train(
    model=model,
    prior=prior,
    steps=5000,
    batch_size=16,
    lr=4e-3
)

Files

FileDescription
model.pyCore architecture (encoders, transformer, decoder)
inference.pyClassifier & regressor with ensembling + chunking
prior.pySCM-based synthetic dataset generator
train.pyTraining loop with multi-task loss
benchmark.pyEvaluation against XGBoost, CatBoost, RandomForest
examples/Usage examples

License

Apache 2.0 β€” bebas dipakai untuk proyek komersial maupun non-komersial.

Citation

If you use this in research, please cite the original nanoTabPFN and TabPFN papers:

@article{hollmann2025tabpfn,
  title={Accurate predictions on small data with a tabular foundation model},
  author={Hollmann, Noah and M{\"u}ller, Samuel and Purucker, Lennart and others},
  journal={Nature},
  year={2025}
}

Acknowledgements

Based on nanoTabPFN by AutoML Group Freiburg. Upgraded toward TabPFN-3 feature parity.

Contributors

anwarrohmadi2006/nanoTabPFN-plus

Enhanced reimplementation of TabPFN with TabPFN-3 features: Randomized Feature Tokens, NaN handling, regression, ensembling, KV caching, synthetic prior training, and more.

Python

0

2 commits

updated May 19, 2026

See the code

README

nanoTabPFN-plus πŸš€

Enhanced reimplementation of TabPFN β€” upgraded from nanoTabPFN toward TabPFN-3.0 parity.

License: Apache 2.0 Python 3.10+ PyTorch

What is this?

nanoTabPFN-plus adalah reimplementasi edukatif dan fungsional TabPFN yang mengintegrasikan semua fitur utama TabPFN-3:

FeaturenanoTabPFN (original)nanoTabPFN-plus
Randomized Feature Tokensβœ—βœ…
NaN / Missing value handlingβœ—βœ…
Regression supportβœ—βœ…
Many-class (>10 classes)βœ—βœ…
Ensembling (n=32+)βœ—βœ…
KV Caching (faster inference)βœ—βœ…
Row chunking (scalable to 1M rows)βœ—βœ…
Temperature calibrationβœ—βœ…
Feature subsampling (high-dim)βœ—βœ…
DAG-aware synthetic priorBasicβœ… SCM-based
Multi-task loss (classification + regression)βœ—βœ…

Architecture

Input (X_train, y_train, X_test)
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   RandomizedFeatureTokenEncoder β”‚  ← NaN handling + per-feature tokens
β”‚   AdvancedTargetEncoder         β”‚  ← multi-class + regression + unknown token
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   CachedTransformerLayer Γ— N    β”‚  ← dual attention (row↔col) + KV cache
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   MultiTaskDecoder              β”‚  ← classification / regression / calibration
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
Predictions (probs / mean+std)

Quick Start

pip install torch numpy scikit-learn networkx
from model import NanoTabPFNPlusModel
from inference import TabPFN3Classifier
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split

# Load data
X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5)

# Create model
model = NanoTabPFNPlusModel(
    embedding_size=128,
    num_attention_heads=4,
    mlp_hidden_size=256,
    num_layers=4,
    num_outputs=10,
    max_features=500
)

# Create classifier with ensembling
classifier = TabPFN3Classifier(model, device='cpu', n_ensemble=8)
classifier.fit(X_train, y_train)
probs = classifier.predict_proba(X_test)
preds = probs.argmax(axis=1)

Training with Synthetic Prior

from prior import SyntheticTabularPrior
from train import train

prior = SyntheticTabularPrior(
    max_rows=1000,
    max_cols=100,
    num_classes=10,
    missing_rate=0.1,
    nonlinear_prob=0.5
)

model, history = train(
    model=model,
    prior=prior,
    steps=5000,
    batch_size=16,
    lr=4e-3
)

Files

FileDescription
model.pyCore architecture (encoders, transformer, decoder)
inference.pyClassifier & regressor with ensembling + chunking
prior.pySCM-based synthetic dataset generator
train.pyTraining loop with multi-task loss
benchmark.pyEvaluation against XGBoost, CatBoost, RandomForest
examples/Usage examples

License

Apache 2.0 β€” bebas dipakai untuk proyek komersial maupun non-komersial.

Citation

If you use this in research, please cite the original nanoTabPFN and TabPFN papers:

@article{hollmann2025tabpfn,
  title={Accurate predictions on small data with a tabular foundation model},
  author={Hollmann, Noah and M{\"u}ller, Samuel and Purucker, Lennart and others},
  journal={Nature},
  year={2025}
}

Acknowledgements

Based on nanoTabPFN by AutoML Group Freiburg. Upgraded toward TabPFN-3 feature parity.

Contributors

Languages

Python

100.0%