Learning problems and trustworthy data
Turn a product question into a measurable prediction task without leaking the answer into the inputs.
On this page
The question for today
What you’ll understand
- Specify the prediction moment, target, population, and decision.
- Separate fitting, model selection, and final evaluation.
- Recognize temporal leakage and correlated examples.
A model cannot rescue an ambiguous question. Suppose a service wants to predict requests that will miss a latency deadline. The first task is deciding exactly when the prediction is made and what information exists at that moment. A feature computed after completion may predict perfectly while being useless operationally. Good machine learning begins with an information contract, before any neural network is trained.
Define the decision before the model
Write a task specification in one sentence: at request arrival, estimate the probability that this request exceeds 200 milliseconds, using only arrival-time features, for traffic from the intended deployment population. State what action follows: perhaps route to spare capacity. Classification predicts a category or event probability; regression predicts a numerical quantity. A useful output also needs an action policy, because a probability alone does not decide whether extra capacity is worth its cost.
Define labels from an auditable process. A timeout is not necessarily a measured latency, and requests cancelled by users may have missing outcomes rather than negative labels. Ask whose examples are absent, how delayed labels arrive, and whether an intervention changes the target. Predicting historical queue delay does not automatically predict delay after a new routing policy changes the queue. This is the distinction between estimating patterns in observed data and establishing the consequences of actions.
A split is a model of the future
Training data fit parameters. Validation data guide decisions such as architecture, regularization, and thresholds. A final test set estimates performance after those decisions are frozen. Random row splits make sense only when rows approximate independent draws from the relevant population. For a future-traffic predictor, split by time; for new-customer generalization, separate customers. A repeated user's nearly identical records across splits can otherwise turn apparent generalization into recognition of that user.
Fit learned preprocessing on the training partition, then apply the resulting transformation unchanged elsewhere. This includes means for normalization, imputers, vocabulary construction when it is learned from task data, and supervised feature selection. Information can leak without an explicit target column: an incident-close timestamp is a future fact, and a cached aggregate may include the very interval being predicted. Keep feature provenance and event-time boundaries alongside the data, rather than treating leakage as a final checklist.
Baselines and uncertainty make progress visible
Build a baseline that a colleague can explain: always predict the historical event rate, use a simple rule, or fit a small linear model. Compare against the operational policy already in use. A complex model that improves average accuracy but doubles costly false alarms may be a regression. Report sample counts, subgroup behavior, and a sensible uncertainty interval; a difference based on ten rare incidents is much less settled than one based on ten thousand.
Data quality is part of the model's behavior. Monitor missingness, unit changes, duplicate identifiers, and shifts in the population after launch. A label definition can remain fixed while its collection mechanism changes. Before trying more capacity, inspect examples where the baseline fails, including disagreements between annotators. An error taxonomy often reveals that a task needs clearer labels, a different prediction horizon, or an explicit abstention path rather than another layer.
Work it through
Find the leaked latency feature
You have 1,000 chronologically ordered requests: 100 exceeded the deadline. Candidate features are arrival queue length, request size, and total execution duration. Design a first experiment.
Declare prediction at arrival. Queue length and request size exist then; total execution duration does not, so remove it even if its validation score looks excellent.
Reserve the final 200 requests as a future-style test, use the first 600 for fitting, and the next 200 for validation. Inspect incident grouping so a single outage does not masquerade as many independent events.
If the training event rate is 0.10, the constant-probability baseline assigns 0.10 to each request. An always-negative classifier can reach roughly 90% accuracy while detecting no deadline misses; compare probability loss and operational false-negative cost too.
The experiment now tests a feasible arrival-time predictor. The 600/200/200 sizes are illustrative choices, not universally optimal split ratios.
The living notebook
Explore the model
Interactive lab · probability
Event frequency is a baseline
Set success probability p and trial count n to inspect exact binomial count probabilities. This assumes independent identical event trials; it does not simulate correlated requests or certify an evaluation split.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA rare event can make a trivial majority prediction look accurate while providing little decision value.
Pause & reason
Check your understanding
Your turn
Try it yourself
A dataset contains 20 messages from each of 100 users. Deployment will serve users never seen during training. Why can a random message split be misleading, and what should you change?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Decide which unit must be new at evaluation time.
Compare with the solution
Messages from one user share vocabulary and behavior. A row split can place the same user's signature in training and test, overstating performance for unseen users. Partition by user, fit transformations on training users, and evaluate the frozen system on held-out users. Preserve a separate time-based evaluation if future drift is also important.
Keep the idea
Take it with you
- Specify what is known when a prediction is made.
- Choose splits that represent the intended deployment novelty.
- Judge a model against a baseline, an action cost, and uncertainty.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.