Data-type contracts: what each kind of data needs
Tables, counts, series, text, images, audio and networks each come with their own preparation, their own split rule and their own checks. Read the contract before choosing a method, and split by whatever will be new when the model is used.
You will be able to
- Name the four parts of a data contract - representation, preparation, split rule and diagnostics
- Pick the split unit for images, audio, series, text and networks
- Say which data types CodeSplash loads and which the Academy only explains
Four questions per data type
ReadBefore any method, a data type answers four questions:
- Representation: what shape do the data take, and what comes out? A table is ; a batch of images is .
- Preparation: what must be fixed first? Units, missing values, sample rates, tokenizers, color ranges.
- Split rule: which rows must stay together so the test is honest?
- Diagnostics: which checks reveal problems for this type?
Together these are its data contract. The Academy's Data contracts page lists all sixteen types the reference covers.
The split unit is whatever will be new
ReadThe test set should be new in the same way future data will be new.
| Data | Keep together |
|---|---|
| TablesData contract: numeric tablesNumeric columns: check units, scale and missingness, and split by subject or site before fitting any transform. | the subject or site, when rows repeat |
| SeriesData contract: time seriesValues in time order: keep that order, fit transforms on the past only, and test with rolling-origin backtests, not random splits. | the future: split by time, never shuffle |
| TextData contract: textToken ids and masks: record the tokenizer and its version, split by document or source, and remove near-duplicates across splits. | the source document; remove near-duplicates |
| ImagesData contract: imagesPixel arrays with a stated layout, color space and range: group splits by subject, scene or source, never by crop or patch. | the subject, scene or source, never crops of one photo |
| AudioData contract: audio waveformsSamples over time per channel: fix the sample rate, channels and level, and split by speaker, recording and source mixture. | the speaker, recording and source mix |
| NetworksData contract: graphs and networksNodes, edges and their features: state direction, weights and self-loops, and say whether test nodes or edges were visible in training. | state transductive or inductive access; hide test edges properly |
Break the rule and the model can memorize the person, the scene or the recording instead of the task.
Preparation is part of the model
ReadEvery preparation step that learns from data is fitted inside the training split: scaling means, vocabularies, normalization of spectrograms, category encoders.
Some choices change the data themselves: an image resize or crop, a tokenizer's version, an audio sample rate, a spectrogram's window and hop. Record them with the model. A model trained on 16 kHz audio and run on 48 kHz recordings will not complain; it will be wrong.
Diagnostics differ too
Read- Tables: missingness patterns, residuals, calibration.
- Counts and text: sparsity, rare tokens, topic stability.
- Series: autocorrelation left in the residuals, error by horizon, drift.
- Images: an error gallery, robustness to blur and noise.
- Audio: listen to failures, look at spectrograms, word error rate by speaker.
- Networks: degree bias, over-smoothing, links that leak the answer.
A single accuracy number hides almost all of these.
What CodeSplash loads
ReadCodeSplash loads tables (numeric, categorical, dates, free text), time series, folders of images, folders of audio and networks given as edge lists. Image, audio and network methods are Experimental.
Video, 3D scenes, point clouds, molecules and live RL environments are explained in the Academy only. Their lessons say so with the readiness label "Needs a data type CodeSplash doesn't load yet".
Check: contracts
CheckpointCheck yourself
You cut each of 200 scans into 50 patches and split patches randomly into train and test. Why is the test score too optimistic?
Show the answer
Answer: a
Split by scan (or by patient) so every patch of a scan is on one side.
Check yourself
A speech classifier will be used on new people. What should the split keep together?
Show the answer
Answer: b
The deployment population is new speakers, so the test speakers must be people the model never heard.
Check yourself
Which split matches the contract for forecasting a series?
Show the answer
Answer: a
Future values must never inform the past. Rolling-origin evaluation repeats this split at several cut points.
Check yourself
A spectrogram model was trained with normalization statistics computed on all recordings, test ones included. What should change?
Show the answer
Answer: a
Normalization learns means and scales from data, so it belongs inside the training split, like any other fitted step.
Recap
Recap- A data contract states representation, preparation, split rule and diagnostics.
- Split by whatever will be new in use: subject, scene, speaker, source, or time.
- CodeSplash loads tables, series, images, audio and networks; video, 3D, molecules and RL environments are Academy-only.
Concepts in this lesson