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

# Model and fitting

> TabPFN experiments model for imputation, outlier detection, and synthetic data generation.

> [!NOTE]
>
> Looking for usage documentation? Check out [Data generation](https://docs.priorlabs.ai/capabilities/data-generation.md) and [Anomaly detection](https://docs.priorlabs.ai/capabilities/anomaly-detection.md).

## `TabPFNUnsupervisedModel`

[ View source ](https://github.com/PriorLabs/tabpfn-extensions/blob/840c15a1848a986b39c85bc17efc61e0e377f983/src/tabpfn_extensions/unsupervised/unsupervised.py#L110)

TabPFN experiments model for imputation, outlier detection, and synthetic data generation.

This model combines a TabPFNClassifier for categorical features and a TabPFNRegressor for
numerical features to perform various experiments learning tasks on tabular data.

Examples:

```python title="Example" theme={null}
>>> tabpfn_clf = TabPFNClassifier()
>>> tabpfn_reg = TabPFNRegressor()
>>> model = TabPFNUnsupervisedModel(tabpfn_clf, tabpfn_reg)
>>>
>>> X = [[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]
>>> model.fit(X)
>>>
>>> X_imputed = model.impute(X)
>>> X_outliers = model.outliers(X)
>>> X_synthetic = model.generate_synthetic_data(n_samples=100)
```

Initialize the `TabPFNUnsupervisedModel`.

```python theme={null}
TabPFNUnsupervisedModel(
    tabpfn_clf: TabPFNClassifier,
    tabpfn_reg: TabPFNRegressor,
)
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `tabpfn_clf` | `TabPFNClassifier` | Required | TabPFNClassifier instance for handling categorical features. If not provided, the model assumes that there are no categorical features in the data. |
| `tabpfn_reg` | `TabPFNRegressor` | Required | TabPFNRegressor instance for handling numerical features. If not provided, the model assumes that there are no numerical features in the data. |

**Attributes**

| Attribute | Type | Description |
| - | - | - |
| `categorical_features` | `list[int]` | List of indices of categorical features in the input data. |

**Raises**

`ValueError`

If both `tabpfn_clf` and `tabpfn_reg` are `None`.

***

## `TabPFNUnsupervisedModel.fit`

[ View source ](https://github.com/PriorLabs/tabpfn-extensions/blob/840c15a1848a986b39c85bc17efc61e0e377f983/src/tabpfn_extensions/unsupervised/unsupervised.py#L261)

Fit the model to the input data.

```python theme={null}
TabPFNUnsupervisedModel.fit(
    X: np.ndarray | torch.Tensor | pd.DataFrame,
    y: np.ndarray | torch.Tensor | pd.Series | None = None,
) -> TabPFNUnsupervisedModel
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `X` | `np.ndarray \| torch.Tensor \| pd.DataFrame` | Required | Union\[[`np.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html), torch.Tensor, [`pd.DataFrame`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html)] Input data to fit the model, shape (n\_samples, n\_features). |
| `y` | `np.ndarray \| torch.Tensor \| pd.Series \| None` | `None` | Optional\[Union\[[`np.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html), torch.Tensor, [`pd.Series`](https://pandas.pydata.org/docs/reference/api/pandas.Series.html)]], default=`None` Target values, shape (n\_samples,). Optional since this is an unsupervised model. |

**Returns**

| Type | Description |
| - | - |
| `TabPFNUnsupervisedModel` | [`TabPFNUnsupervisedModel`](https://docs.priorlabs.ai/api-reference/python/tabpfn-extensions/unsupervised/model#unsupervised-unsupervised-tabpfnunsupervisedmodel)     Fitted model instance (self). |

***

## `TabPFNUnsupervisedModel.init_model_and_get_model_config`

[ View source ](https://github.com/PriorLabs/tabpfn-extensions/blob/840c15a1848a986b39c85bc17efc61e0e377f983/src/tabpfn_extensions/unsupervised/unsupervised.py#L204)

Initialize TabPFN models for use in unsupervised learning.

This function provides compatibility with different TabPFN implementations.
It tries to initialize the model using the appropriate method based on the
TabPFN implementation in use.

```python theme={null}
TabPFNUnsupervisedModel.init_model_and_get_model_config() -> None
```

**Raises**

`RuntimeError`

If model initialization fails

**Returns**

| Type | Description |
| - | - |
| `None` | — |

***

## `TabPFNUnsupervisedModel.set_categorical_features`

[ View source ](https://github.com/PriorLabs/tabpfn-extensions/blob/840c15a1848a986b39c85bc17efc61e0e377f983/src/tabpfn_extensions/unsupervised/unsupervised.py#L181)

Set categorical feature indices for the model.

```python theme={null}
TabPFNUnsupervisedModel.set_categorical_features(
    categorical_features: list[int],
) -> None
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `categorical_features` | `list[int]` | Required | List of indices of categorical features |

**Returns**

| Type | Description |
| - | - |
| `None` | — |

***

## `TabPFNUnsupervisedModel.use_classifier_`

[ View source ](https://github.com/PriorLabs/tabpfn-extensions/blob/840c15a1848a986b39c85bc17efc61e0e377f983/src/tabpfn_extensions/unsupervised/unsupervised.py#L539)

Determine whether to use a classifier or regressor for a feature.

```python theme={null}
TabPFNUnsupervisedModel.use_classifier_(
    column_idx: int,
    y: torch.Tensor | np.ndarray,
) -> bool
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `column_idx` | `int` | Required | Index of the column to check |
| `y` | `torch.Tensor \| np.ndarray` | Required | Values of the feature |

**Returns**

| Type | Description |
| - | - |
| `bool` | `True` if a classifier should be used, `False` for a regressor |

***

## `efficient_random_permutation`

[ View source ](https://github.com/PriorLabs/tabpfn-extensions/blob/840c15a1848a986b39c85bc17efc61e0e377f983/src/tabpfn_extensions/unsupervised/unsupervised.py#L1023)

Generate multiple unique random permutations of the given indices.

```python theme={null}
efficient_random_permutation(
    indices: list[int],
    n_permutations: int = 10,
) -> list[tuple[int, ...]]
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `indices` | `list[int]` | Required | List of indices to permute |
| `n_permutations` | `int` | `10` | Number of unique permutations to generate |

**Returns**

| Type | Description |
| - | - |
| `list[tuple[int, ...]]` | List of unique permutations |

***

## `efficient_random_permutation_`

[ View source ](https://github.com/PriorLabs/tabpfn-extensions/blob/840c15a1848a986b39c85bc17efc61e0e377f983/src/tabpfn_extensions/unsupervised/unsupervised.py#L1049)

Generate a single random permutation from the given indices.

```python theme={null}
efficient_random_permutation_(
    indices: list[int],
) -> tuple[int, ...]
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `indices` | `list[int]` | Required | List of indices to permute |

**Returns**

| Type | Description |
| - | - |
| `tuple[int, ...]` | A tuple representing a random permutation of the input indices |


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