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

# Quickstart

> Score new rows from past rows, and check how good the scores are.

This page takes you from a CSV file to predictions. You need an API key. See [Access and API keys](https://docs.tabsutra.com/authentication.md).

## Set up

The examples in these docs use Python with `requests` and `pandas`. They also work as plain HTTP calls from any language.

```python theme={null}
import json, os
import pandas as pd
import requests

API = "https://api.tabsutra.com"
HEADERS = {"Authorization": f"Bearer {os.environ['TABSUTRA_API_KEY']}"}

def records(df: pd.DataFrame) -> list:
    """A DataFrame as a list of rows for a JSON body, with dates as ISO strings."""
    return json.loads(df.to_json(orient="records", date_format="iso", double_precision=15))
```

## The example data

The example is a table of loan applications. Each row is one application. The column `defaulted` holds the answer for past applications: whether the loan went 90 days past due within 12 months. The past applications are all more than 12 months old, so every answer in the file is final.

```csv applications.csv theme={null}
application_id,income,loan_amount,term_months,employment,region,applied_on,defaulted
A1001,52000,12000,36,salaried,North,2025-01-04,no
A1002,31000,15000,60,self-employed,West,2025-01-06,yes
A1003,78000,9000,24,salaried,South,2025-01-07,no
...
```

The rows to score have the same columns, without `defaulted`.

## Step 1: send the past rows

The rows whose answer you know are called the context. Sending them to `/v1/fit` means the model reads them once. Nothing is trained.

```python Python theme={null}
past = pd.read_csv("applications.csv")
fitted = requests.post(f"{API}/v1/fit", headers=HEADERS, json={
    "rows": records(past), "target": "defaulted", "task": "classification", "id_column": "application_id",
}).json()
context_id = fitted["context_id"]
print(fitted["report"]["columns"])
```

```bash curl theme={null}
curl https://api.tabsutra.com/v1/fit-file \
  -H "Authorization: Bearer $TABSUTRA_API_KEY" \
  -F file=@applications.csv \
  -F target=defaulted \
  -F task=classification \
  -F id_column=application_id
```

The response holds a `context_id` and a report. The report lists every column with the type it was read as, and the reason. Here `income` and `loan_amount` are numbers, `employment` and `region` are categories, `applied_on` is a date, and `application_id` is an id that is not read as a feature. If a type is wrong, you can override it. See [Column types](https://docs.tabsutra.com/concepts/column-types.md).

## Step 2: score new rows

```python Python theme={null}
new = pd.read_csv("new_applications.csv")
scored = requests.post(f"{API}/v1/predict", headers=HEADERS, json={
    "context_id": context_id, "rows": records(new),
}).json()
print(scored["predictions"][:3])
```

```bash curl theme={null}
curl https://api.tabsutra.com/v1/predict-file \
  -H "Authorization: Bearer $TABSUTRA_API_KEY" \
  -F file=@new_applications.csv \
  -F context_id=YOUR_CONTEXT_ID \
  -F format=csv
```

Each prediction is keyed by the id column. For a classification task you get the most likely label and a probability for each class.

```json theme={null}
{
  "id": "A2001",
  "label": "no",
  "probabilities": {"no": 0.91, "yes": 0.09}
}
```

The context stays available for a while, so you can score more rows against the same `context_id` without sending the past rows again. If it has expired, send them again. The same rows always give the same `context_id`.

## Step 3: check how good the scores are

Before you rely on the scores, measure them on rows whose answer you know. `/v1/evaluate` holds out a share of your rows, predicts them from the rest, and compares the result with a simple baseline.

```python theme={null}
result = requests.post(f"{API}/v1/evaluate", headers=HEADERS, json={
    "rows": records(past), "target": "defaulted", "task": "classification", "id_column": "application_id",
    "time_column": "applied_on", "target_delay_days": 365, "holdout": 0.2,
}).json()
print(result["ours"], result["baseline"])
```

Because `time_column` is given, the held-out rows are the latest 20% of applications. Each one is predicted only from what was known on its application date. The setting `target_delay_days` says that an application's answer becomes known 365 days after the application, at the end of its 12-month window. So a held-out application reads only the outcomes of applications made more than a year before it. This is the out-of-time test that credit teams already use. It is a fairer test than a random split for any data that changes over time.

## A shortcut for one-off jobs

If your rows to score sit in the same file as the past rows, leave their target empty and call `/v1/fill`. The rows with an answer become the context, and the rows with an empty answer are predicted.

```python theme={null}
filled = requests.post(f"{API}/v1/fill", headers=HEADERS, json={
    "rows": records(pd.read_csv("all_applications.csv")), "target": "defaulted",
    "task": "classification", "id_column": "application_id",
}).json()
```

## Next steps

* To forecast series, read [Forecasting](https://docs.tabsutra.com/guides/forecasting.md).
* If your rows form sequences, such as monthly snapshots per account, read [Sequences](https://docs.tabsutra.com/guides/sequences.md).
* If your data is spread over several tables, read [Databases](https://docs.tabsutra.com/guides/databases.md).
* Read [Time and leakage](https://docs.tabsutra.com/concepts/time-and-leakage.md) before you evaluate anything that changes over time.


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