> ## 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.

# Grouped data

> Tell TabPFN which rows belong together, such as visits of one patient or transactions of one customer.

Many tables hold several rows per entity: repeat patient visits, transactions per customer, readings per machine. Name the column that identifies the entity with `group_col`, and TabPFN treats the rows of a group as related.

> [!NOTE]
>
> `group_col` without Thinking requires `tabpfn-client` **0.10.0 or later**. Automatic grouping of test rows into requests requires **0.11.2 or later**.

***

## Two kinds of grouped data

| | One label per row | One label per group |
| - | - | - |
| Example | Each visit of a patient has its own outcome, such as whether that visit led to readmission. | Each patient has one diagnosis, repeated on all of their visit rows. |
| The target describes | the row | the whole group |
| What to pass | `group_col` | `group_col`, plus `presets="grouped"` for one prediction per group |

In both cases the rows of a group are not independent: visits of one patient share the patient's health, age and history. Naming the group lets TabPFN use that structure instead of treating every row as a separate case. Keep it in mind for evaluation too: hold out whole groups, as with sklearn's `GroupShuffleSplit`, or a test score measures how well the model recognises groups it has already seen.

***

## One label per row

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

# X_*: one row per visit, with a patient_id column. y_train: readmitted after that visit.
clf = TabPFNClassifier(model_path="v4_default", group_col="patient_id")
clf.fit(X_train, readmitted_train)
probs = clf.predict_proba(X_test)  # X_test keeps the patient_id column
```

* `group_col` takes a column name, or a list of columns whose joint value is the group.
* `X` passed to `fit` and to `predict` must be a pandas DataFrame that holds the named columns. Pass column names, not indices.
* The model replaces the group columns with one categorical feature that holds the group.
* Leave out the `grouped` preset here: it would give every visit of a patient the same prediction, while their outcomes differ.

***

## One label per group

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

# X_*: one row per visit, with a patient_id column. y_train: the patient's diagnosis,
# the same value on every visit row of that patient.
clf = TabPFNClassifier(
    model_path="v4_default",
    group_col="patient_id",
    presets="grouped",
)
clf.fit(X_train, diagnosis_train)
probs = clf.predict_proba(X_test)  # every visit of a patient gets the same probabilities
patient_probs = probs[~X_test["patient_id"].duplicated().to_numpy()]  # one row per patient
```

The `grouped` preset does two things:

* It adds per-group summaries of the features, so the model sees each row together with what the rest of its group looks like.
* It averages the predictions of all rows of a group, so each group gets one prediction.

Without the preset, a TabPFN-4 fit adds the per-group summaries on its own when every training group has a single label and some group has more than one row; the response's `inference_config` then shows `APPEND_GROUP_AGGREGATES`. Each row still gets its own prediction. Setting `APPEND_GROUP_AGGREGATES` in `inference_config` or passing any `presets` turns this automatic choice off.

The summaries and the averaging use only the rows sent in one predict call. **All rows of a group must be in the same call**; otherwise each part of the group gets its own prediction. The preset has no effect without `group_col`.

***

## Large test sets

From `tabpfn-client` 0.11.2, `predict()` splits a test set that exceeds the API's per-request limits across several requests and returns the predictions in row order. With `group_col`, the client packs whole groups into each request. If a single group has more test rows than one request accepts, `predict()` raises `ValueError` naming the group before sending anything; predict fewer rows of that group.

One request takes at most 1,000,000 test rows on TabPFN-4 and 1,100,000 on TabPFN-3.5, and fewer when the training set is large: training rows × test rows may not exceed 10 trillion on TabPFN-4 and 250 billion on TabPFN-3.5. With 1 million training rows, that is 1,000,000 test rows per request on TabPFN-4 and 250,000 on TabPFN-3.5. A fit with `fit_mode="fit_with_cache"` takes 10,000 test rows per request, and very wide test sets are also capped by their cell count. To check before predicting:

```python theme={null}
largest_group = X_test.groupby("patient_id").size().max()
print(largest_group)  # must fit in one request
```

`submit_predict()` sends a single request and raises `ValueError` when the test set needs several.

***

## Grouped and time-ordered rows with Thinking

[Thinking mode](https://docs.priorlabs.ai/capabilities/thinking-mode.md) also accepts time columns. Specifying group and time columns can improve predictions on data with related rows or a time sequence.

| Parameter | What it does |
| - | - |
| `group_col` | Column, or list of columns, that identifies groups of related rows, such as a patient or session ID. |
| `time_col` | Column that holds time, as datetimes or numbers, for rows ordered in time. Thinking only. |
| `group_time_col` | Column that orders the rows within a group, such as transaction time for each customer. Thinking only. |

Rules, checked by the client before any data is uploaded. A violation raises `ValueError`:

* `time_col` and `group_time_col` work only with Thinking.
* `group_col` and `time_col` cannot be combined.
* `group_time_col` requires `group_col`.
* `X` passed to `fit` and to `predict` must be a pandas DataFrame that holds every named column.

```python theme={null}
import numpy as np
import pandas as pd
from sklearn.model_selection import GroupShuffleSplit
from tabpfn_client import TabPFNClassifier

rng = np.random.default_rng(0)
n_rows = 600
X = pd.DataFrame(
    {
        "patient_id": rng.integers(0, 120, n_rows),
        "age": rng.integers(20, 90, n_rows),
        "heart_rate": rng.normal(75, 12, n_rows),
        "blood_pressure": rng.normal(125, 15, n_rows),
    }
)
y = (X["heart_rate"] + rng.normal(0, 10, n_rows) > 80).astype(int)

# Hold out whole patients, so no test patient appears in the training data.
splitter = GroupShuffleSplit(n_splits=1, test_size=0.2, random_state=0)
train_idx, test_idx = next(splitter.split(X, y, groups=X["patient_id"]))
X_train, X_test = X.iloc[train_idx], X.iloc[test_idx]
y_train = y.iloc[train_idx]

clf = TabPFNClassifier(model_path="v4_default", thinking_mode=True, group_col="patient_id")
clf.fit(X_train, y_train)
probs = clf.predict_proba(X_test)  # X_test keeps the patient_id column
```

***

## REST API

Without Thinking, set `group_col` and `presets` in `task_config.tabpfn_config`:

```json theme={null}
{
  "train_set_upload_id": "<your-upload-id>",
  "task_config": {
    "task": "classification",
    "tabpfn_config": {
      "model_path": "v4_default",
      "group_col": "batch_id",
      "presets": "grouped"
    }
  }
}
```

With Thinking, set the columns in `thinking_config` instead. Thinking rejects `group_col` in `tabpfn_config`.

```json theme={null}
{
  "train_set_upload_id": "<your-upload-id>",
  "task_config": {
    "task": "classification",
    "tabpfn_config": {"model_path": "v4_default"}
  },
  "tabpfn_systems": ["preprocessing", "text", "thinking"],
  "thinking_config": {
    "effort": "mini",
    "group_col": "patient_id"
  }
}
```

The training and test uploads must both hold the named columns. See the [REST quickstart](https://docs.priorlabs.ai/api/rest-quickstart.md) for uploads and polling.

***

> [card] [Thinking mode](https://docs.priorlabs.ai/capabilities/thinking-mode.md)
>
> Spend more compute on the fit for better predictions.

> [card] [Sample weights](https://docs.priorlabs.ai/capabilities/sample-weights.md)
>
> Weight training rows and mark uncertain labels.


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