> ## 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. Record counts on the platform are sequences, while the ingest progress line counts rows, and a sequence split across two ingests is counted twice.

## Ingest with the CLI

Pass the CSV file, or a folder that holds only that CSV. Ingest the training and the test split separately:

```bash theme={null}
tracebloc data ingest ./vitals_train.csv --task time_series_classification --name icu_vitals_sepsis_train --intent train --label-column label \
  --schema 'sequence_id:VARCHAR(64),timestamp:TIMESTAMP,heart_rate:FLOAT,resp_rate:FLOAT,temperature:FLOAT,spo2:FLOAT,lactate:FLOAT,label:INT' --holds patient_data
tracebloc data ingest ./vitals_test.csv --task time_series_classification --name icu_vitals_sepsis_test --intent test --label-column label \
  --schema 'sequence_id:VARCHAR(64),timestamp:TIMESTAMP,heart_rate:FLOAT,resp_rate:FLOAT,temperature:FLOAT,spo2:FLOAT,lactate:FLOAT,label:INT' --holds patient_data
```

`--holds patient_data` marks the dataset as patient data. Pass `--holds open_data` or `--holds synthetic_data` only when your data is open data or synthetic data. Leave `--holds` out on a terminal and the CLI asks; in a script, the dataset is marked as patient data. The mark decides which [use case types](https://docs.tracebloc.io/create-use-case/define.md#step-2-data-&-evaluation) you can create on the dataset.

Without `--schema`, the CLI infers a type for every column. Passing it, as above, pins `sequence_id` as text and `timestamp` as a calendar type. Quote it: `VARCHAR(64)` contains shell characters. `--schema` replaces the inferred schema, so list every column you want stored. Including the label column in `--schema` is fine: the ingestor drops it from the stored schema.

## 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** (with the CLI, inferred for you) | 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](https://docs.tracebloc.io/create-use-case/templates.md#the-ingest-yaml-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](https://docs.tracebloc.io/create-use-case/templates.md#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 taken from it. The `ingest.yaml` above ingests it as is; only `csv:` changes to wherever you staged the file.

## Model settings for this dataset

When you link a model, the platform checks it against the dataset (see [model parameters by task](https://docs.tracebloc.io/join-use-case/start-training.md#model-parameters-by-task)):

* `num_feature_points` must equal the number of stored columns minus the label, `sequence_id` and `timestamp`. For the sample, that is 5.
* `output_classes` must equal the number of distinct labels. For the sample, that is 2.
* `sequence_length` is the number of time steps the model sees per sequence. Shorter sequences are zero-padded to it, and longer ones keep their most recent steps. The sample's sequences have 3 to 7 steps.

The model-zoo templates default to 9 features and a `sequence_length` of 60, so edit them. Feature columns reach the model sorted by column name, whatever order the CSV or `schema` uses.

## Next steps

* Ingest the data: [Prepare Data](https://docs.tracebloc.io/create-use-case/prepare-dataset.md)
* Shared rules for every template: [Dataset templates](https://docs.tracebloc.io/create-use-case/templates.md)


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