> ## Documentation Index
> Fetch the complete documentation index at: https://docs.priorlabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> TabPFN-3 and later versions support up to 1,000,000 rows, subject to feature count and checkpoint/API limits.
> For large datasets, use per-estimator subsampling, e.g. inference_config={"SUBSAMPLE_SAMPLES": 100_000}, in TabPFNClassifier or TabPFNRegressor from tabpfn or tabpfn_client.
> Pass raw pandas DataFrames to fit and predict. Categorical strings/categories, raw text, and missing feature values are handled automatically; no manual integer/one-hot encoding, imputation, scaling, or outlier removal is needed.

# TabPFN Quickstart

> Classification and regression with TabPFN.

By
Eliott Kalfon[LinkedIn](https://www.linkedin.com/in/eliott-kalfon/)

[Open in Colab](https://colab.research.google.com/github/PriorLabs/tabpfn-cookbook/blob/main/notebooks/quickstart.ipynb)

# TabPFN Quickstart

Use TabPFN's pretrained model with scikit-learn's `fit` / `predict` workflow. Start with the hosted API; try local inference at the end.

![TabPFN pretraining on synthetic datasets and prediction on unseen data](https://raw.githubusercontent.com/PriorLabs/tabpfn-cookbook/main/visuals/quickstart/diagram.svg)

## Setup

Install the client, local package, and example dependencies.

```python theme={null}
%pip install -q tabpfn tabpfn-client scikit-learn
```

## Authenticate

Sign in at [Prior Labs](https://ux.priorlabs.ai), accept the license, and copy your API key into a Colab secret named `TABPFN_TOKEN`. Enable notebook access to that secret.

```python theme={null}
import os
from google.colab import userdata
from tabpfn_client import set_access_token

os.environ["TABPFN_TOKEN"] = userdata.get("TABPFN_TOKEN")
set_access_token(userdata.get('TABPFN_TOKEN'))
```

## Classification

Split the German credit dataset, then evaluate held-out predictions with ROC AUC and accuracy. `fit` supplies context to the pretrained model without updating its weights.

```python theme={null}
from sklearn.datasets import fetch_openml
from sklearn.metrics import accuracy_score, roc_auc_score
from sklearn.model_selection import train_test_split

from tabpfn_client import TabPFNClassifier

X, y = fetch_openml(data_id=46562, as_frame=True, return_X_y=True)

X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.33, random_state=42, stratify=y
)

clf = TabPFNClassifier()
clf.fit(X_train, y_train)

prediction_probabilities = clf.predict_proba(X_test)
print("ROC AUC:", roc_auc_score(y_test, prediction_probabilities[:, 1]))

predictions = clf.predict(X_test)
print("Accuracy", accuracy_score(y_test, predictions))
```

```console theme={null}
ROC AUC: 0.8041890769163497
Accuracy 0.7666666666666667
```

## Regression

Predict diabetes progression and report mean squared error, mean absolute error, and R².

```python theme={null}
from sklearn.datasets import load_diabetes
from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score

from tabpfn_client import TabPFNRegressor

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 = TabPFNRegressor()
reg.fit(X_train, y_train)

predictions = reg.predict(X_test)
print("Mean Squared Error (MSE):", mean_squared_error(y_test, predictions))
print("Mean Absolute Error (MAE):", mean_absolute_error(y_test, predictions))
print("R-squared (R^2):", r2_score(y_test, predictions))
```

```console theme={null}
Mean Squared Error (MSE): 2644.03219611575
Mean Absolute Error (MAE): 40.70198539838399
R-squared (R^2): 0.5405885672117363
```

## Run locally

Switch the import to `tabpfn` to run inference on your machine. The first use downloads model weights; a GPU is recommended for this example.

```python theme={null}
from tabpfn import TabPFNClassifier

X, y = fetch_openml(data_id=46562, as_frame=True, return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.33, random_state=42, stratify=y
)

clf = TabPFNClassifier()  # downloads weights on first use, then runs locally
clf.fit(X_train, y_train)
print("Local ROC AUC:", roc_auc_score(y_test, clf.predict_proba(X_test)[:, 1]))
```

```console theme={null}
Local ROC AUC: 0.804145349599895
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.