# The model serving unscaled features

A trained capacity prediction model loads correctly, but its predictions are
wrong. Compare the training and inference paths, then restore the fitted
training-time transformation without retraining or altering the model.

## Before you begin

Use Bash and Python 3.11 or later in a private local environment. Install the
pinned model library into a virtual environment:

```sh
LAB_VENV="$(mktemp -d)"
python3 -m venv "$LAB_VENV"
. "$LAB_VENV/bin/activate"
python -m pip install -r requirements.txt
```

Installing packages needs internet access. The lab trains a real scikit-learn
`StandardScaler` and `LinearRegression` pipeline on synthetic data. It does
not deploy a service or use a cloud account or real workload measurements.

The generated `.lab-state` contains a serialized model. Python model artifacts
can execute code during loading: only use files created by your own lab run,
never load an untrusted artifact. Setup refuses to overwrite an existing
state directory.

## Investigate

```sh
./setup.sh
cat training.csv
cat inference.json
./lab.sh inspect
./lab.sh predict 150 3
```

The arguments are synthetic requests per second and error percentage. The
printed reference prediction is produced through the trained pipeline; the
served prediction follows the inference configuration. Diagnose the difference
and update `inference.json`, without changing the data, model or predictor.

```sh
./verify.sh
./teardown.sh
```

Verification checks the original dataset and generated model, and compares
served predictions with the trained pipeline on several unseen inputs.
Teardown removes only the lab-generated model and state marker; it refuses
unexpected files. The fitted example does not validate production model
quality, monitoring, real-world causality or deployment behavior. Deactivate
and remove the temporary virtual environment separately when done.
