AI Professionals Bootcamp | Week 3
2025-12-29
models/runs/, data/processed/, outputs/ are gitignored on purposereports/model_card.md open (we will update the evaluation plan section)Note
If you get stuck: read the error, then ask for clarification — not code.
Goal: run ml-baseline train to create a versioned run folder and save baseline metrics + a trained model.
Bootcamp • SDAIA Academy
train command anatomy (run_id + artifacts)By the end of today, you can:
uv run ml-baseline train --target ... and find saved artifactsRun yesterday’s work and confirm it still works.
Checkpoint: you see features.csv or features.parquet, and tests pass.
Yesterday you wrote a dataset contract:
Tip
Today you will use those decisions to split and train consistently.
Today: Split + Baseline + Train (your first run folder). Tomorrow: we’ll go deeper on evaluation artifacts and the input schema.
Train
What should happen - a new folder appears in models/runs/<run_id>/ - models/registry/latest.txt updates to the newest run - baseline metrics are saved to the run folder
Splits that don’t lie (holdout + stratify)
A split answers:
“If we train on some rows, how well do we do on new rows?”
Without a split, you only know:
Tip
Treat the holdout set like production: don’t “study” it.
Random split is OK when:
Our sample dataset has 1 row per user_id, so random split is fine.
If your target is imbalanced (example: 5% positives):
Note
Stratify only makes sense for classification (not regression).
Pick the best split strategy:
Checkpoint: you can justify each choice in 1 sentence.
If the same entity appears in train and holdout:
Typical group columns: - user_id, customer_id, device_id, patient_id
from sklearn.model_selection import train_test_split
def random_split(df, *, target, test_size, seed, stratify):
y = df[target]
strat = y if stratify else None
train, test = train_test_split(
df, test_size=test_size, random_state=seed, stratify=strat
)
return train.reset_index(drop=True), test.reset_index(drop=True)Minimum requirement: stratify for binary classification when possible.
Question: What problem does stratification prevent?
Answer: train and holdout accidentally having very different class balance.
When you return: be ready to explain why “beat the dummy” is required.
Baselines + metrics (beat the dummy)
A baseline is the simplest thing that could work:
Tip
If your model can’t beat the baseline, something is wrong (or there is no signal).
That usually means one of these:
A baseline result is a diagnostic, not an insult.
Before you choose a metric, ask:
Note
Today we focus on decision metrics: accuracy / precision / recall / F1.
Suppose:
What is accuracy?
Checkpoint: you have a number between 0 and 1.
Warning
95% accuracy can still mean “your model never finds positives.”
Classification (binary) - accuracy - precision - recall - F1
Regression - MAE (Mean Absolute Error)
Tip
Pick one primary metric and write it in your model card today.
Optional ≠ unimportant. It’s just not required to ship a baseline this week.
Fit on the train split, evaluate on the holdout split.
You see:
Checkpoint: you can answer in 3 short sentences.
When you return: we will connect the concepts to the train command + artifacts.
train command anatomy (run_id + artifacts)
ml-baseline train does at a high levelml-baseline train does (in 8 steps)data/processed/features.*models/runs/<run_id>/models/registry/latest.txtEach run folder is a snapshot:
Tip
A run folder is how you make training reproducible and reviewable.
Inside models/runs/<run_id>/ focus on:
metrics/baseline_holdout.json ✅ (your floor)model/model.joblib ✅ (your saved model)You may see extra files (schema, tables, holdout metrics). We’ll explain them more on Day 3.
Match the question → the file:
Checkpoint: you can name the file path for each.
models/runs/<run_id>/metrics/baseline_holdout.jsonmodels/registry/latest.txtmodels/runs/<run_id>/model/model.joblibNote
We don’t need “perfect” metrics today — we need repeatable training.
train turns your feature table into a versioned runWhen you return: start Hands-on Task 1 immediately.
Run training + inspect baseline + update model card
Minimum ✅ - uv run ml-baseline train --target ... runs successfully - a new run folder exists under models/runs/<run_id>/ - metrics/baseline_holdout.json exists - model/model.joblib exists - you updated reports/model_card.md (evaluation plan section) - 1+ commit pushed to GitHub
Optional ⭐ - run training with a different seed and compare metrics - try --split-strategy time or --split-strategy group on your own dataset (if you have one)
Checkpoint: terminal prints Saved run: .../models/runs/<run_id>.
You should see something like:
Saved run: .../models/runs/2025-12-29T...Z__classification__seed42Note
Your run_id will be different. That’s good: each run is versioned.
List the run folders, open latest.txt, and confirm the minimum artifacts exist
macOS/Linux
Windows PowerShell
Checkpoint: you can see metrics/ and model/ inside the run.
Ignore the “…” for now. We’ll use more artifacts tomorrow.
macOS/Linux
Windows PowerShell
Checkpoint: you can explain the baseline in 1–2 sentences.
Tip
Write your baseline result (1–2 numbers) into your eval_summary.md later this week.
Open reports/model_card.md and update:
Checkpoint: your model card evaluation plan has no blanks.
Checkpoint: all commands exit with code 0.
git status"w3d2: train + baseline"Checkpoint: your commit appears on GitHub.
Missing target column → check --target matches your file’s column namedata/processed/features.* existsuv sync --extra parquetWarning
Make one change at a time. Re-run train. Don’t “randomly tweak”.
⭐ If you finish early:
--seed 7 and compare baseline metrics--split-strategy timeIn 1–2 sentences each:
Due: before Day 3 (Dec 30, 2025)
uv run ml-baseline train --target <your_target>metrics/baseline_holdout.jsonmodel/model.joblibreports/model_card.md evaluation plan sectionDeliverable: GitHub repo link + the run_id from your latest run.
Tip
Do not commit models/runs/. Commit code + reports.