TabPFN Tabular Foundation Model¶
This page contains usage examples and installation instructions of TabPFN. Please find additional instructions on our Classifiers and Regressors on the respective subpages. An in-depth technical documentation of our software interfaces can be found in the API Reference
Installation¶
You can access our models through our API (https://github.com/automl/tabpfn-client) or via our user interface built on top of the API (https://www.priorlabs.ai/tabpfn-gui). We will release open weights models soon, currently we are available via api and via our user interface built on top of the API.
Example usage¶
import numpy as np
import sklearn
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from tabpfn import TabPFNClassifier
# Create a classifier
clf = TabPFNClassifier(fit_at_predict_time=True)
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
clf.fit(X_train, y_train)
preds = clf.predict_proba(X_test)
y_eval = np.argmax(preds, axis=1)
print('ROC AUC: ', sklearn.metrics.roc_auc_score(y_test, preds, multi_class='ovr'), 'Accuracy', sklearn.metrics.accuracy_score(y_test, y_eval))
from tabpfn import TabPFNRegressor
from sklearn.datasets import load_diabetes
from sklearn.model_selection import train_test_split
import numpy as np
import sklearn
reg = TabPFNRegressor(device='auto')
X, y = load_diabetes(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
reg.fit(X_train, y_train)
preds = reg.predict(X_test)
print('Mean Squared Error (MSE): ', sklearn.metrics.mean_squared_error(y_test, preds))
print('Mean Absolute Error (MAE): ', sklearn.metrics.mean_absolute_error(y_test, preds))
print('R-squared (R^2): ', sklearn.metrics.r2_score(y_test, preds))