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

# Tables

> One row per case: fit, predict, fill and evaluate.

A table has one row per case, such as a customer, a loan or a claim, and the rows do not depend on each other. Loan applications, insurance claims, property listings and survey responses are often of this kind.

The examples use the `API`, `HEADERS` and `records` set up in the [Quickstart](https://docs.tabsutra.com/quickstart.md).

## Fit and predict

```python theme={null}
fitted = requests.post(f"{API}/v1/fit", headers=HEADERS, json={
    "rows": records(past_claims), "target": "claim_amount", "task": "regression",
    "id_column": "claim_id", "target_range": [0, None],
}).json()

scored = requests.post(f"{API}/v1/predict", headers=HEADERS, json={
    "context_id": fitted["context_id"], "rows": records(new_claims),
    "outputs": ["mean", "median", "interval"],
}).json()
```

The settings of `/v1/fit` are:

| Setting | Default | Meaning |
| - | - | - |
| `target` | required | The column to predict. Rows where it is empty are left out of the context. |
| `task` | required | `classification` or `regression`. |
| `id_column` | none | A column that names each row. It is never read as a feature, and the predictions are keyed by it. |
| `column_types` | inferred | Overrides the type of some columns. See [Column types](https://docs.tabsutra.com/concepts/column-types.md). |
| `max_context` | 0 | Use at most this many context rows. 0 means every row. |
| `embed_dims` | 8 | The number of numeric columns made from each text, image or embedding column. |
| `target_range` | none | Regression only: a range the outputs are clipped to. `null` means no bound on that side. |

The rows you predict need the same columns as the context, apart from the target. Extra columns are allowed. They are not read, and the report lists them.

## Large contexts

The model reads every context row. With a very large table you may want to limit the context, for speed. With `max_context`, the same table always keeps the same rows, whatever order its rows arrive in. The report says how many rows were left out.

## Fill

When the rows to predict are in the same table as the context, leave their target empty and call `/v1/fill`. The rows with a target are the context, and the rows with an empty target are predicted.

```python theme={null}
filled = requests.post(f"{API}/v1/fill", headers=HEADERS, json={
    "rows": records(customers), "target": "segment", "task": "classification", "id_column": "customer_id",
}).json()
```

## Evaluate

`/v1/evaluate` holds out a share of the rows, predicts them from the rest, and scores the predictions.

```python theme={null}
result = requests.post(f"{API}/v1/evaluate", headers=HEADERS, json={
    "rows": records(customers_with_segment), "target": "segment", "task": "classification",
    "id_column": "customer_id", "holdout": 0.2,
}).json()
```

The same table always gives the same split, whatever order its rows arrive in. With a `time_column`, the latest rows are held out instead. See [Sequences](https://docs.tabsutra.com/guides/sequences.md).

The scores are:

| Task | Scores | Baseline |
| - | - | - |
| Classification | accuracy, log loss, AUC (one class against the rest, averaged over the classes) | always predicting the class shares of the context |
| Regression | MAE of the median, RMSE of the mean, R², and the share of rows inside the 80% interval | always predicting the context's median (for MAE) and mean (for RMSE and R²) |

The share of rows inside the 80% interval should be close to 0.8. If it is much lower, the intervals are too narrow for your data.

## Files

Each call has a `-file` variant, such as `/v1/fit-file` and `/v1/predict-file`, that takes a CSV or Parquet file and the settings as form fields. A predict call can return JSON, CSV or Parquet, as you choose with `format`.


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