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

# Time-series classification

> Dataset template for time-series classification: one CSV of time-step rows grouped by sequence_id with one label per sequence, ingest.yaml and the checks the data ingestor runs.

Predict a class for a whole sequence — for example one outcome per patient stay, device or session from its multivariate time series. The dataset is a single CSV with **one row per time step**; the rows of one sequence share a `sequence_id` and are ordered by `timestamp` within that sequence. The label is per sequence and repeats on every row of it.

## Folder layout

```text theme={null}
/data/shared/icu-sepsis/
└── vitals.csv
```

## Data CSV

```csv theme={null}
sequence_id,timestamp,heart_rate,resp_rate,temperature,spo2,lactate,label
patient_001,2024-03-10 08:00:00,69.0,25.3,36.1,94.8,3.43,1
patient_001,2024-03-10 09:00:00,71.6,25.6,38.6,95.0,,1
patient_001,2024-03-10 10:00:00,78.1,20.6,39.1,90.3,3.53,1
patient_002,2024-03-11 08:00:00,105.9,19.0,37.1,98.5,2.47,0
patient_002,2024-03-11 09:00:00,80.7,16.3,37.4,90.3,,0
```

| Column                      | Meaning                                                                                                                                                                                                                                                                                                   |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sequence_id`               | **Fixed name.** The entity whose rows form one sequence (patient, device, session). Declared in `schema` as `VARCHAR`; no row may leave it empty.                                                                                                                                                         |
| `timestamp`                 | **Fixed name.** Orders the rows within a sequence. Declared in `schema` either as a calendar type (`TIMESTAMP`, `DATETIME`, `DATE` — use ISO 8601 values) or as a numeric step index (`INT`, `FLOAT`, ...). Must be non-decreasing within each sequence; sequences may be interleaved. No missing values. |
| feature columns             | Numeric, declared in `schema`. Empty cells are allowed (a lab value not measured at every step).                                                                                                                                                                                                          |
| label column (`label` here) | Named by `label:`, not declared in `schema`. **Constant within each sequence.** At least two distinct values across the dataset.                                                                                                                                                                          |

Sequences may have different lengths. Keep each sequence complete within one ingest — the dataset summary counts sequences, not rows, and a sequence split across two ingests is counted twice.

## ingest.yaml

```yaml theme={null}
apiVersion: tracebloc.io/v1
kind: IngestConfig
category: time_series_classification
table: icu_vitals_sepsis_train
intent: train
csv: /data/shared/icu-sepsis/vitals.csv
schema:
  sequence_id: VARCHAR(64)   # group key — fixed name
  timestamp: TIMESTAMP       # order key within a sequence — fixed name; INT for a step index
  heart_rate: FLOAT
  resp_rate: FLOAT
  temperature: FLOAT
  spo2: FLOAT
  lactate: FLOAT             # blank cells allowed
label: label
```

| Field                         | Required  | Meaning                                                                                                                                          |
| ----------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `csv`                         | yes       | Path to the data CSV.                                                                                                                            |
| `schema`                      | **yes**   | Must declare both `sequence_id` and `timestamp`, plus the numeric feature columns. A non-text type for `sequence_id` is accepted with a warning. |
| `label`                       | yes       | Name of the per-sequence outcome column. String shorthand — this is a classification task.                                                       |
| `time_column`                 | leave out | The order column is always `timestamp`; any other value is rejected at preflight.                                                                |
| `data_id`                     | no        | Must **not** use `strategy: column` with `column: sequence_id` — row ids are unique per row, so every sequence would collapse to one row.        |
| `columns`, `spec.csv_options` | no        | See [the contract](/create-use-case/templates#the-ingestyaml-contract).                                                                          |

## What the ingestor checks

| Check                       | Rejects                                                                                                                                                                                          |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Sequence group              | A CSV without `sequence_id`; rows with an empty `sequence_id`; a `data_id` column strategy pointed at `sequence_id`.                                                                             |
| Label constant within group | Any sequence whose label value changes between its rows (including a mix of a value and empty cells).                                                                                            |
| Per-group time ordered      | A missing or unparseable `timestamp` on any row; rows within a sequence that are not sorted ascending by `timestamp`; day-first/month-first ambiguous dates when `timestamp` is a calendar type. |
| Numeric columns             | A non-numeric value in any schema column other than `sequence_id` and `timestamp`. Empty cells are allowed.                                                                                      |
| Data types                  | Duplicate headers, schema columns missing from the CSV, values that do not match their type (every schema column except `timestamp`).                                                            |
| Label diversity             | Fewer than two distinct label values.                                                                                                                                                            |

Plus the [checks every ingest runs](/create-use-case/templates#checks-every-ingest-runs). After the rows are stored, an integrity pass removes any sequence that lost rows to a failed insert, so a sequence is stored whole or not at all, and the run then exits with an error.

## Sample dataset

The template ships 30 hourly rows of synthetic ICU vitals for six sequences (3 to 7 steps each) with five `FLOAT` features (`heart_rate`, `resp_rate`, `temperature`, `spo2`, `lactate` — the last with legal blanks) and a binary per-sequence `label` — the rows shown above are its first rows. The `ingest.yaml` above ingests it as is; only `csv:` changes to wherever you staged the file.

## Next steps

* Stage the data and run the ingest: [Prepare Data](/create-use-case/prepare-dataset)
* Shared rules for every template: [Dataset templates](/create-use-case/templates)
