Module 02 Activity
Scenario
Every later module depends on data arriving in the right shape. Build that pipeline once, correctly.
Task
- Load a tabular dataset into tensors, setting dtype explicitly.
- Confirm your target's shape matches your prediction's shape, not just its length.
- Split into train, validation and test with a seeded generator. Verify no overlap.
- Wrap them in DataLoaders. Note how many batches you get and how large the last one is.
- Standardise features using training statistics only, and return those statistics.
Deliverable
A reusable function that takes a DataFrame and returns loaders plus the scaling statistics, and a short note on where the leak would have been.
Check your work
- A (n,) target against an (n, 1) prediction broadcasts to (n, n). Check with
.shape, not by eye. - 20 items at batch size 6 gives four batches: 6, 6, 6, 2.
- Split indices must not intersect.
len(train_idx & val_idx)is 0. - Re-running with the same seed reproduces the identical split.
The leak to name
Standardising before splitting lets validation data influence the training transformation. The score improves and the improvement is fictional.
