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

# Scoring

> Scoring

## Installation

```bash theme={null}
pip install tabpfn-extensions
```

<div className="python-reference-heading">
  <h2 id="scoring-scoring-utils-safe-roc-auc-score">
    `safe_roc_auc_score`
  </h2>

  <a className="python-reference-source" href="https://github.com/PriorLabs/tabpfn-extensions/blob/840c15a1848a986b39c85bc17efc61e0e377f983/src/tabpfn_extensions/scoring/scoring_utils.py#L23" aria-label="View source for safe_roc_auc_score"><span aria-hidden="true">\</></span> View source <span aria-hidden="true">↗</span></a>
</div>

Compute the Area Under the Receiver Operating Characteristic Curve (ROC AUC) score.

This function is a safe wrapper around `sklearn.metrics.roc_auc_score` that handles
cases where the input data may have missing classes or binary classification problems.

```python theme={null}
safe_roc_auc_score(
    y_true,
    y_score,
    **kwargs,
)
```

**Parameters**

<div className="python-reference-table">
  | Parameter | Type | Default | Description |
  | - | - | - | - |
  | <span id="scoring-scoring-utils-safe-roc-auc-score--y-true" /><code className="python-reference-parameter">y\_<wbr />true</code> | <code className="python-reference-type">array-like of shape (n\_samples,)</code> | Required | `True` binary labels or binary label indicators. |
  | <span id="scoring-scoring-utils-safe-roc-auc-score--y-score" /><code className="python-reference-parameter">y\_<wbr />score</code> | <code className="python-reference-type">array-like of shape (n\_samples,) or (n\_samples, n\_classes)</code> | Required | Target scores, can either be probability estimates of the positive class, confidence values, or non-thresholded measure of decisions. |
  | <span id="scoring-scoring-utils-safe-roc-auc-score--kwargs" /><code className="python-reference-parameter">\*\*kwargs</code> | <code className="python-reference-type">dict</code> | — | Additional keyword arguments to pass to `sklearn.metrics.roc_auc_score`. |
</div>

**Returns**

<div className="python-reference-table python-reference-returns">
  | Type | Description |
  | - | - |
  | — | `float`: The ROC AUC score. |
</div>

**Raises**

`ValueError`

If there are missing classes in `y_true` that cannot be handled.

***

<div className="python-reference-heading">
  <h2 id="scoring-scoring-utils-score-classification">
    `score_classification`
  </h2>

  <a className="python-reference-source" href="https://github.com/PriorLabs/tabpfn-extensions/blob/840c15a1848a986b39c85bc17efc61e0e377f983/src/tabpfn_extensions/scoring/scoring_utils.py#L100" aria-label="View source for score_classification"><span aria-hidden="true">\</></span> View source <span aria-hidden="true">↗</span></a>
</div>

General function to score classification predictions.

```python theme={null}
score_classification(
    optimize_metric: Literal["roc", "auroc", "accuracy", "f1", "log_loss"],
    y_true,
    y_pred,
    sample_weight = None,
    *,
    y_pred_is_labels: bool = False,
)
```

**Parameters**

<div className="python-reference-table">
  | Parameter | Type | Default | Description |
  | - | - | - | - |
  | <span id="scoring-scoring-utils-score-classification--optimize-metric" /><code className="python-reference-parameter">optimize\_<wbr />metric</code> | <code className="python-reference-type">Literal\["roc", "auroc", "accuracy", "f1", "log\_loss"]</code> | Required | The metric to use for scoring the predictions. |
  | <span id="scoring-scoring-utils-score-classification--y-true" /><code className="python-reference-parameter">y\_<wbr />true</code> | <code className="python-reference-type">array-like of shape (n\_samples,)</code> | Required | `True` labels or binary label indicators. |
  | <span id="scoring-scoring-utils-score-classification--y-pred" /><code className="python-reference-parameter">y\_<wbr />pred</code> | <code className="python-reference-type">array-like of shape (n\_samples,) or (n\_samples, n\_classes)</code> | Required | Predicted labels, probabilities, or confidence values. |
  | <span id="scoring-scoring-utils-score-classification--sample-weight" /><code className="python-reference-parameter">sample\_<wbr />weight</code> | <code className="python-reference-type">array-like of shape (n\_samples,), default=None</code> | `None` | Sample weights. |
  | <span id="scoring-scoring-utils-score-classification--y-pred-is-labels" /><code className="python-reference-parameter">y\_<wbr />pred\_<wbr />is\_<wbr />labels</code> | <code className="python-reference-type">bool</code> | `False` | — |
</div>

**Returns**

<div className="python-reference-table python-reference-returns">
  | Type | Description |
  | - | - |
  | — | `float`: The score for the specified metric. |
</div>

**Raises**

`ValueError`

If an unknown metric is specified.

***

<div className="python-reference-heading">
  <h2 id="scoring-scoring-utils-score-regression">
    `score_regression`
  </h2>

  <a className="python-reference-source" href="https://github.com/PriorLabs/tabpfn-extensions/blob/840c15a1848a986b39c85bc17efc61e0e377f983/src/tabpfn_extensions/scoring/scoring_utils.py#L163" aria-label="View source for score_regression"><span aria-hidden="true">\</></span> View source <span aria-hidden="true">↗</span></a>
</div>

General function to score regression predictions.

```python theme={null}
score_regression(
    optimize_metric: Literal["rmse", "mse", "mae", "r2"],
    y_true,
    y_pred,
    sample_weight = None,
)
```

**Parameters**

<div className="python-reference-table">
  | Parameter | Type | Default | Description |
  | - | - | - | - |
  | <span id="scoring-scoring-utils-score-regression--optimize-metric" /><code className="python-reference-parameter">optimize\_<wbr />metric</code> | <code className="python-reference-type">Literal\["rmse", "mse", "mae", "r2"]</code> | Required | The metric to use for scoring the predictions. |
  | <span id="scoring-scoring-utils-score-regression--y-true" /><code className="python-reference-parameter">y\_<wbr />true</code> | <code className="python-reference-type">array-like of shape (n\_samples,)</code> | Required | `True` target values. |
  | <span id="scoring-scoring-utils-score-regression--y-pred" /><code className="python-reference-parameter">y\_<wbr />pred</code> | <code className="python-reference-type">array-like of shape (n\_samples,)</code> | Required | Predicted target values. |
  | <span id="scoring-scoring-utils-score-regression--sample-weight" /><code className="python-reference-parameter">sample\_<wbr />weight</code> | <code className="python-reference-type">array-like of shape (n\_samples,), default=None</code> | `None` | Sample weights. |
</div>

**Returns**

<div className="python-reference-table python-reference-returns">
  | Type | Description |
  | - | - |
  | — | `float`: The score for the specified metric. |
</div>

**Raises**

`ValueError`

If an unknown metric is specified.


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