The holdout that trained the scaler
A real scikit-learn evaluation fits its scaler on the whole dataset, including held-out observations. Restore the train-only preprocessing boundary.

The scenario
The split is recorded in the dataset, but the preprocessing configuration lets holdout values influence the fitted scaler. Fix the fit boundary without changing data or the holdout split.
Mission objectives
- Compare the scaler's fitted statistics with the training and holdout data.
- Fit preprocessing only on the training partition.
- Verify the fitted scaler and predictions against an independent train-only pipeline.
Lab README
The holdout that trained the scaler
A classifier is evaluated on held-out data, but its preprocessing was fitted on the entire dataset. Restore the boundary so the holdout cannot influence the scaler.
Before you begin
Use Bash and Python 3.11 or later on a disposable machine. Create a virtual environment and install the pinned library:
LAB_VENV="$(mktemp -d)"
python3 -m venv "$LAB_VENV"
. "$LAB_VENV/bin/activate"
python -m pip install -r requirements.txt
The lab fits a real scikit-learn StandardScaler and k-nearest-neighbors
classifier on fixed synthetic data. The split is supplied by the lab; it does
not validate model quality or demonstrate a particular production failure.
No cloud, real data or serialized model is used.
./setup.sh
./lab.sh inspect
Compare dataset.csv, the scaler means and policy.json. Change the fitting
scope without altering the dataset, split or model code.
./verify.sh
./teardown.sh
Verification compares fitted statistics and predictions against a separate train-only scikit-learn pipeline. Teardown creates or deletes no service or cloud resources; deactivate and remove the separate virtual environment when finished.
Get the lab
Download and inspect the installer before running it. It checks the archive's SHA-256 digest and refuses to overwrite an existing lab directory.
curl -fsSLO https://devops.download/labs/mlops-04-preprocessing-data-leak.sh less mlops-04-preprocessing-data-leak.sh
bash mlops-04-preprocessing-data-leak.sh
cd labs/mlops-04-preprocessing-data-leak
./setup.shWhen you've made your changes, run ./verify.sh. Remove lab resources with ./teardown.sh.
Need a nudge?
Hint #1
A holdout must not contribute to any fitted preprocessing statistics.
Hint #2
Fit the scaler using the training partition, then transform both partitions with that same fitted scaler.
Hint #3 · Learning paths on opsbreakfix.com
Solved it?
Continue learning with the paths on opsbreakfix.com.
Continue to opsbreakfix.com ↗