The prediction using the wrong class
A real scikit-learn classifier returns probabilities for two classes, but the serving configuration selects the healthy class as incident risk.

The scenario
The classifier's probability columns are ordered by its classes, not by an assumed business meaning. Correct the selected positive label while preserving the trained model and synthetic data.
Mission objectives
- Inspect the fitted classifier's class order and predicted probabilities.
- Select the incident class rather than the healthy class.
- Verify predictions on unseen healthy and incident-like samples.
Lab README
The prediction using the wrong class
A trained classifier's probability is presented as incident risk, but its serving configuration selects the wrong class. Inspect the model's actual class order and correct the selected label.
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 logistic regression on fixed synthetic data each time it runs. It does not deploy a service, load a model artifact or use real telemetry. This toy classifier is not a validated production model.
./setup.sh
./lab.sh inspect
./lab.sh score 9
Inspect training.csv and inference.json. Select the correct positive label
without changing the data or model code, then run:
./verify.sh
./teardown.sh
The verifier checks unseen samples and the original training data. Teardown creates or deletes no service or cloud resources; deactivate and remove the separate temporary 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-03-positive-class-mismatch.sh less mlops-03-positive-class-mismatch.sh
bash mlops-03-positive-class-mismatch.sh
cd labs/mlops-03-positive-class-mismatch
./setup.shWhen you've made your changes, run ./verify.sh. Remove lab resources with ./teardown.sh.
Need a nudge?
Hint #1
Inspect the model's classes_ order rather than assuming a probability column means incident.
Hint #2
The serving configuration chooses a label; incident risk must use the incident label.
Hint #3 · Learning paths on opsbreakfix.com
Solved it?
Continue learning with the paths on opsbreakfix.com.
Continue to opsbreakfix.com ↗