Define task and split IDs
Quick answer
A prediction task needs a contract: one row represents a particular event, the features are available at prediction time, and the target is observed later. For this chapter, predict the processing time in seconds of an independent synthetic batch job using its known input size in blocks. Regression predicts a numeric target. Assign unique job IDs to training (learn parameters), validation (choose a model) and test (final assessment) before fitting. IDs identify rows; they are not predictive features. Examples use local Python 3.13.5 and scikit-learn 1.8.0 where imported. All fixtures are synthetic; ByteMind library execution is unverified.
Check split membership
Eight independent jobs have fixed split IDs. Check both separation and complete coverage before using any labels.
train = ['J01','J02','J03','J04']validation = ['J05','J06']test = ['J07','J08']all_ids = train + validation + testprint(len(all_ids), len(set(all_ids)))print(set(all_ids) == {f'J{i:02d}' for i in range(1,9)})Expected output:
8 8TrueEvery job occurs once and all eight expected IDs are present. The assignment is fixed, not random.
Build a feature matrix and target vector
Each training row contains an ID, input size in blocks and observed processing time. Keep the ID outside the feature matrix.
rows = [('J01',1,3), ('J02',2,5), ('J03',3,7), ('J04',4,9)]X = [[size] for _, size, seconds in rows]y = [seconds for _, size, seconds in rows]print(X)print(y)Expected output:
[[1], [2], [3], [4]][3, 5, 7, 9]X has four rows and one feature column; y has four numeric outcomes in matching order. The target is known after processing, not before.
Common mistakes
Do not split after copying or augmenting observations; related jobs may need a group split, and chronological predictions may need time-ordered splits. A unique row ID alone does not guarantee independence. A feature derived from completed processing time leaks the target. The tiny synthetic fixture deliberately assumes independent jobs and does not represent real workloads.
Practice and next steps
Write a prediction contract for estimating delivery duration using only data known before dispatch. Identify one unavailable future feature. Then inspect the split-ID exercise. The separate pure-Python exercise assesses the underlying calculation, not library execution.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Define task and split IDs — knowledge check
Apply experiment design and evaluation reasoning to synthetic examples.
What is the prediction unit here?
Which feature is available before the job runs?
What does the validation split support?
An ID is present in train and test. What should you do?
Which split strategy suits future predictions from dated data?