Skip to content
Visual explainer 5h to learn 5 steps

ML capstone: dataset, model brief and naive baseline

Choose a licensed tabular dataset, write a model brief, define a versioned split and naive baseline, and complete a leakage review.

By Invicly Tech, , in AI and Machine Learning with Python. About 13 minutes to read.

Topic 32 of 34

In short

The first capstone milestone fixes the ground rules before any real model is trained. You pick a tabular dataset you are allowed to use, write a one-page model brief, freeze a versioned split and score a naive baseline that every later model must beat. You finish with a written leakage review, so the numbers you report later can be trusted.

Think of it like this: It is like marking the start line and timing a slow walker before a race: without the line and the walker's time, nobody can say whether the runners were fast.

Explained simply

The capstone is one small machine learning project done properly from start to finish. The running example here predicts whether a customer support ticket will miss its service level agreement (SLA), the promised reply time, using a synthetic dataset you generate with a fixed seed. You can swap in a public dataset instead. Either way it should be tabular, a few thousand rows, and trainable on a normal laptop in seconds.

Start with a model brief, a one-page note written before any code. It says which decision the model helps, who uses the output, what exactly is predicted and when, and what score would make the project worth shipping. The brief stops you from drifting into a different problem halfway through.

Next, fix the data. Write down where it came from, its licence, the date you downloaded it and a checksum, which is a short fingerprint of the file. Then split it into training, validation and test parts and save that split to a file, so every later run uses exactly the same rows.

Before training anything clever, score a naive baseline: a model so simple it is almost a joke, such as predicting the average breach rate for every ticket. Real models must beat it clearly. Finally, read every column and ask whether it would be known when the prediction is made. Columns that sneak in the answer are called leakage.

Press Play on a diagram to walk through it one step at a time.

FlowFrom question to a trusted baseline
  1. 1
    Model brief

    Decision, target, horizon, success bar

  2. 2
    Dataset and licence

    Source, version, terms of use

  3. 3
    Versioned split

    Rule plus a saved list of row ids

  4. 4
    Naive baseline

    Constant or simple rule, scored once

  5. 5
    Leakage review

    Every feature checked against prediction time

MapWhere leakage hides
Leakage review
  • Target leakage
    • Feature only known after the outcome
    • Example: first_response_minutes
  • Split leakage
    • Same customer in train and test
    • Duplicate rows across splits
  • Time leakage
    • Future rows used for training
    • Rolling stats that peek ahead
  • Preprocessing leakage
    • Scaler or encoder fitted on all rows
  • Tuning leakage
    • Test set used to pick models or thresholds
FlowVersioning a split so anyone can rebuild it
  1. 1
    Checksum raw file

    SHA-256 recorded in the data card

  2. 2
    Stable row ids

    ticket_id, never the row position

  3. 3
    Apply the split rule

    Date cut-offs or group assignment

  4. 4
    Write split_v1.csv

    Row id and split name only

  5. 5
    Hash and commit

    File plus hash in git

In depth

Choosing a dataset you are allowed to use

Pick data whose terms you can read and follow. Many datasets on the UCI Machine Learning Repository and OpenML carry a Creative Commons licence such as CC BY 4.0, which allows reuse with credit, but always check the licence shown on the dataset page itself rather than assuming. Record the source URL, licence, version or download date and a SHA-256 checksum in a data card next to the file.

Avoid personal data you do not need. A synthetic dataset, generated by a short script with a fixed random seed, has no licence or privacy risk and lets you plant known effects, such as queue size raising the breach rate, so you can check whether the model finds them. The downside is that it is cleaner than real data; say so in the model card. Good public alternatives are bank marketing or bike-sharing demand tables.

  • Record source, licence, version and checksum
  • Prefer CC BY or similar clear terms
  • Synthetic data: no licence risk, but too tidy
  • Drop personal fields you do not need

Writing the model brief

The brief is one page and is written before you open a notebook. It names the decision (which tickets get an early escalation), the user (the support team lead), the target and horizon (breach of the 24-hour SLA, predicted at ticket creation), and the unit of observation (one ticket). It lists features that exist at creation time, the success metric and the minimum bar, such as PR AUC at least 0.10 above the baseline and recall of at least 0.70 at a flag rate the team can handle.

It also lists the cost of each error type, out-of-scope uses (never use it to rate individual agents) and the people who sign off. Keep it in the repository and update it when decisions change.

MapParts of a model brief
Model brief
  • Decision
    • What action the score triggers
    • Who acts on it
  • Target
    • Exact label definition
    • Prediction time and horizon
  • Data
    • Unit of observation
    • Features known at prediction time
  • Success
    • Primary metric
    • Minimum bar over baseline
  • Limits
    • Error costs
    • Out-of-scope uses
    • Sign-off

Splits that copy real use

The test set should look like the data the model will meet after launch. If the model scores tomorrow's tickets, split by time: train on older months, validate on the next block, test on the newest block. If the same customer or device appears many times, keep all of its rows on one side with a group split (GroupKFold or GroupShuffleSplit in scikit-learn). Only when rows are truly independent and order does not matter is a stratified random split right.

To version the split, save a small file mapping each row id to train, val or test, hash it and commit the file and hash. Give it a name such as split_v1. If you ever change the split, create split_v2 and never compare scores across versions.

CompareWhich split fits the problem
Stratified random
  • Independent rows
  • No time order
  • Keeps class balance
  • StratifiedKFold
Group
  • Repeated customers or devices
  • Whole group on one side
  • Stops memorising an entity
  • GroupKFold
Time
  • Predicting the future
  • Train old, test new
  • Shows ageing of the model
  • TimeSeriesSplit

Naive baselines and the leakage review

For classification, DummyClassifier with strategy prior predicts the training positive rate for everyone; most_frequent predicts the majority class. For regression, DummyRegressor with mean or median does the same. For demand forecasting, the seasonal naive forecast (same day last week) is the classic baseline and is often hard to beat. A simple hand rule, such as flagging all urgent tickets, is a useful second baseline because it is what the team would do without a model.

The leakage review is a short table: one row per feature, the time it becomes known, and a verdict. Add checks for duplicate rows across splits and for any preprocessing fitted before splitting. Keep the table in the repository; it goes into the model card later.

  • DummyClassifier: prior, most_frequent, stratified
  • DummyRegressor: mean, median
  • Seasonal naive for forecasts
  • Leakage table: feature, known when, verdict

Learn it in 5 short steps

About 1h each. Track them with a timer in your plan.

  1. 1
    Pick a licensed dataset and record its source~1h
  2. 2
    Write the model brief~1h
  3. 3
    Define and version the split~1h
  4. 4
    Score a naive baseline~1h
  5. 5
    Review for leakage~1h

Key points

  • Keep the capstone CPU-first: a few thousand rows of tabular data, scikit-learn and a laptop are enough.
  • Record the dataset source, version or download date, licence and a file checksum before you start.
  • The split must copy real use: if the model predicts future cases, split by time, not at random.
  • A naive baseline, such as always predicting the training positive rate, sets the bar every candidate must clear.
  • Check each feature with one question: would this value really be known at the moment of prediction?

Key terms

Tap a card to flip it. 0/6 known

Examples

python
import pandas as pd
from sklearn.dummy import DummyClassifier
from sklearn.metrics import average_precision_score

df = pd.read_csv('data/tickets_v1.csv', parse_dates=['created_at'])
split = pd.read_csv('data/split_v1.csv')
df = df.merge(split, on='ticket_id')
train, test = df[df.split == 'train'], df[df.split == 'test']
X_cols = ['priority', 'channel', 'queue_size', 'agent_tenure_days']

base = DummyClassifier(strategy='prior').fit(train[X_cols], train.breached)
p = base.predict_proba(test[X_cols])[:, 1]
print('train breach rate:', round(train.breached.mean(), 3))
print('baseline PR AUC:', round(average_precision_score(test.breached, p), 3))

Score a constant baseline on the frozen split. Its PR AUC equals the test positive rate, which is the bar to beat.

Generate a synthetic ticket dataset with a known signal

This script creates 5,000 tickets across about ten months with a fixed seed, so every learner gets the same file. Breach probability rises with queue size, urgent priority and email channel, and falls with agent tenure. Because you planted the signal, you know what a good model should discover. Run it once, record the checksum of the CSV and treat the file as read-only from then on. Prerequisites: Python 3.10 or later with NumPy and pandas.

python
import numpy as np, pandas as pd
rng = np.random.default_rng(7)
n = 5000
df = pd.DataFrame({
    'ticket_id': np.arange(n),
    'created_at': pd.Timestamp('2026-01-01') + pd.to_timedelta(rng.integers(0, 300 * 24, n), unit='h'),
    'priority': rng.choice(['low', 'normal', 'high', 'urgent'], n, p=[.3, .45, .2, .05]),
    'channel': rng.choice(['email', 'chat', 'phone'], n),
    'queue_size': rng.poisson(20, n),
    'agent_tenure_days': rng.integers(5, 900, n),
})
logit = (-3 + 0.06 * df.queue_size - 0.002 * df.agent_tenure_days
         + 1.2 * (df.priority == 'urgent') + 0.5 * (df.channel == 'email'))
df['breached'] = rng.random(n) < 1 / (1 + np.exp(-logit))
df.sort_values('created_at').to_csv('data/tickets_v1.csv', index=False)

Write and fingerprint a time-based split

The split uses two date cut-offs: tickets before 1 August are training, those up to 15 September are validation and the rest are test. Only the ticket id and split name are saved, so the file is small and easy to review in a pull request. The printed hash goes into the README and the model card. Expected evidence: three counts that add up to 5,000 and a 12-character hash that stays the same every time you rerun the script.

python
import hashlib, pandas as pd
df = pd.read_csv('data/tickets_v1.csv', parse_dates=['created_at'])
cut_val, cut_test = pd.Timestamp('2026-08-01'), pd.Timestamp('2026-09-15')
df['split'] = 'train'
df.loc[df.created_at >= cut_val, 'split'] = 'val'
df.loc[df.created_at >= cut_test, 'split'] = 'test'
df[['ticket_id', 'split']].to_csv('data/split_v1.csv', index=False)
digest = hashlib.sha256(open('data/split_v1.csv', 'rb').read()).hexdigest()[:12]
print(df.split.value_counts().to_dict(), 'split_v1 sha256:', digest)

Quick reference

  • Data card: source URL, licence, version or download date, SHA-256 checksum, known gaps.
  • Model brief: decision, user, target, prediction time, unit of observation, success bar, out-of-scope uses.
  • Future predictions: split by time. Repeated entities: group split. Independent rows: stratified split.
  • DummyClassifier(strategy='prior') gives a PR AUC equal to the positive rate.
  • Seasonal naive (same period last cycle) is the baseline for demand forecasts.
  • Leakage test for each feature: is this value known at prediction time?
  • Never look at the test set until the final report; choose everything on validation.

Common mistakes

  • Choosing a random split for a problem where the model will only ever see future data.
  • Using a dataset scraped from the web with no clear licence, or one that holds personal data you do not need.
  • Skipping the baseline, then reporting 92 percent accuracy on data where 92 percent of rows are one class.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Your model will score new support tickets each morning. Which split best matches that use?

Question 2

28 percent of tickets breach. A model has 92 percent accuracy. What is the most useful next step?

Question 3

3Which feature is leakage when predicting SLA breach at ticket creation?

Question 4

4Why save a file of row ids for the split instead of only the random seed?

Question 5

5What belongs in the out-of-scope section of the model brief for the SLA model?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Write a data card for your dataset with source, licence, download date, row count, checksum and one known limitation.

  2. Exercise 2medium

    Score two baselines on the validation split: DummyClassifier(strategy='prior') and a rule that flags every urgent ticket. Report PR AUC for the first and precision and recall for the second.

  3. Exercise 3hard

    Add a leaky column first_response_minutes to the synthetic data (longer when breached), train a quick model with and without it, and show the score jump. Then write the leakage review table row that rejects it.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Can I use a Kaggle dataset for the capstone?
Yes, if its licence allows your use and you record it. Many Kaggle datasets are re-uploads with unclear terms, so prefer the original source or a dataset with an explicit licence.
Is synthetic data good enough for a portfolio project?
It is good for showing a sound process, because you know the true signal. Say clearly that the data is synthetic and, if you can, repeat the pipeline on one public dataset.
How big should the test set be?
Big enough to hold a few hundred positive cases if possible, so metrics are not driven by a handful of rows. With rare positives, that matters more than the percentage.

Go deeper

ShareXLinkedInWhatsApp