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

# Anomaly detection

> Calculate outlier scores as the log of the arithmetic mean (AM) of the densities across the permutations used to approximate the chain rule.

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

## `TabPFNUnsupervisedModel.density_`

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

Generate density predictions for a specific feature based on other features.

This internal method is used by the imputation and outlier detection algorithms
to model the conditional probability distribution of one feature given others.

```python theme={null}
TabPFNUnsupervisedModel.density_(
    X_predict: torch.Tensor,
    X_fit: torch.Tensor,
    conditional_idx: list[int],
    column_idx: int,
) -> tuple[Any, torch.Tensor, torch.Tensor]
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `X_predict` | `torch.Tensor` | Required | Input data for which to make predictions |
| `X_fit` | `torch.Tensor` | Required | Training data to fit the model |
| `conditional_idx` | `list[int]` | Required | Indices of features to condition on |
| `column_idx` | `int` | Required | Index of the feature to predict |

**Returns**

| Type | Description |
| - | - |
| `tuple[Any, torch.Tensor, torch.Tensor]` | tuple containing:     - The fitted model (classifier or regressor)     - The filtered features used for prediction     - The target feature values to predict |

***

## `TabPFNUnsupervisedModel.outliers`

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

Calculate outlier scores as the log of the arithmetic mean (AM) of the densities across the permutations used to approximate the chain rule.

The logsumexp trick is used to compute the log of the AM to address the risk of over- or underflow.

```python theme={null}
TabPFNUnsupervisedModel.outliers(
    X: torch.Tensor | np.ndarray | pd.DataFrame,
    n_permutations: int = 10,
) -> torch.Tensor
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `X` | `torch.Tensor \| np.ndarray \| pd.DataFrame` | Required | Union\[torch.Tensor, [`np.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html), [`pd.DataFrame`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html)] Samples to calculate outlier scores for, shape (n\_samples, n\_features) |
| `n_permutations` | `int` | `10` | int, default=10 Number of permutations to use for more robust probability estimates. Higher values may produce more stable results but increase computation time. |

**Returns**

| Type | Description |
| - | - |
| `torch.Tensor` | torch.Tensor:     Tensor of outlier scores as log(AM(densities)), (lower values indicate more likely outliers), shape (n\_samples,). |

**Raises**

`RuntimeError`

If the model initialization fails

`ValueError`

If the input data has incompatible dimensions

***

## `TabPFNUnsupervisedModel.outliers_pdf`

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

Calculate the log\_pdf from numerical features only.

This method filters out categorical features and only considers numerical features
for outlier detection.

```python theme={null}
TabPFNUnsupervisedModel.outliers_pdf(
    X: torch.Tensor,
    n_permutations: int = 10,
) -> torch.Tensor
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `X` | `torch.Tensor` | Required | Input data tensor |
| `n_permutations` | `int` | `10` | Number of permutations to use for the outlier calculation |

**Returns**

| Type | Description |
| - | - |
| `torch.Tensor` | log\_pdf (lower values indicate more likely outliers). |

***

## `TabPFNUnsupervisedModel.outliers_pmf`

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

Calculate log\_pmf from categorical features only.

This method filters out numerical features and only considers categorical features
for outlier detection.

```python theme={null}
TabPFNUnsupervisedModel.outliers_pmf(
    X: torch.Tensor,
    n_permutations: int = 10,
) -> torch.Tensor
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `X` | `torch.Tensor` | Required | Input data tensor |
| `n_permutations` | `int` | `10` | Number of permutations to use for the outlier calculation |

**Returns**

| Type | Description |
| - | - |
| `torch.Tensor` | Tensor of outlier scores (lower values indicate more likely outliers) |

***

## `TabPFNUnsupervisedModel.outliers_single_permutation_`

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

Compute the chain-rule log-density / log-probability of each row under one permutation.

```python theme={null}
TabPFNUnsupervisedModel.outliers_single_permutation_(
    X: torch.tensor,
    feature_permutation: list[int] | tuple[int],
) -> torch.tensor
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `X` | `torch.tensor` | Required | — |
| `feature_permutation` | `list[int] \| tuple[int]` | Required | — |

**Returns**

| Type | Description |
| - | - |
| `torch.tensor` | — |


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