TabPFN is a transformer-based foundation model for tabular data that leverages prior-data based learning to achieve strong performance on small-to-medium sized datasets without requiring task-specific training. Currently at version 7.1.1, it is actively developed by Prior Labs and offers fast, zero-shot predictions, often outperforming tuned tree-based models and AutoML systems on suitable datasets.
pip install tabpfnVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of TabPFNClassifier with a scikit-learn compatible interface for binary classification. For optimal performance, specify `device='cuda'` if a GPU is available. Note that the first execution may prompt a browser window for license acceptance.
For very large datasets, consider sampling, hybrid approaches (e.g., with Random Forests), or commercial versions. Use TabPFN Extensions for 'many_class' problems.
Ensure a CUDA-enabled PyTorch installation and set `device='cuda'` for `TabPFNClassifier` or `TabPFNRegressor`. If no GPU is available, consider using the TabPFN API Client for hosted inference.
Upgrade your Python environment to 3.9, 3.10, or 3.11.
Feed raw or minimally preprocessed numerical and categorical data directly to TabPFN. Let the model handle feature transformations.
Always use batch prediction mode by passing all test samples (`X_test`) in a single call to `clf.predict(X_test)` or `clf.predict_proba(X_test)`. If `X_test` is very large, split it into chunks (e.g., 1000 samples each) and process in batches.
Remove the `N_ensemble_configurations` argument. Check the documentation for available parameters in your installed version. The default ensemble behavior is usually handled internally.
If you have a GPU, set `clf = TabPFNClassifier(device='cuda')` for significantly faster inference. Ensure PyTorch with CUDA support is installed.
Reduce the size of your training data (e.g., by sampling) or test data (by chunking `X_test` for prediction). Consider using a GPU with more VRAM, or switch to CPU inference (which will be slower).
For truly constant targets, consider adding tiny, practically insignificant noise to the target variable `y` or implement explicit checks to skip fitting if `y` is constant and handle such cases separately (e.g., by predicting the constant value directly).
Ensure `tabpfn` is installed with `pip install tabpfn`. Verify your Python environment meets the `>=3.9` requirement. If using a virtual environment, activate it before installing and importing.