Lawfare Group → Knowledge Institute → Lawfare Academy
← AI 301 — Machine Learning, Neural Networks and Language
Weeks 1–2
Problem formulation, baselines and honest experiments
Learning objectives
- Explain and trace the mechanisms in problem formulation, baselines and honest experiments.
- Apply the method to the worked example and changed-condition exercise.
- Identify assumptions, failure cases and the evidence needed to justify a result.
Machine learning estimates a rule from data rather than specifying every decision by hand. Begin with the prediction target, observation unit and moment of use. Classification predicts categories; regression predicts numerical outcomes; unsupervised methods describe structure without the same labeled target. A method cannot be evaluated until success is defined.
A baseline creates a comparison that is hard to evade. For regression it might predict the training mean; for classification it might use the majority class or a simple documented rule. A complex model that does not improve a relevant baseline may add cost without value. Compare on the same split, metric and allowable features. Include preprocessing within the fitted pipeline so evaluation reflects the complete learned procedure.
Training estimates parameters; validation supports model choices; a held-out test estimates the selected procedure. These roles can be implemented through cross-validation, but the separation of purposes remains. Random splits assume a relationship between observations that may fail for time series or repeated customers. A reproducible experiment records seeds, versions and data construction, while recognizing that deterministic reproduction is different from scientific generalization.
Worked reasoning The baseline uses the training targets only. It predicts 20 for both unseen cases, producing errors 5 and 5. A candidate must be compared with that same held-out target list and metric. Computing the baseline from test targets would contaminate the comparison, even if the arithmetic happened to yield the same number.
Extended teaching and laboratory
An experiment compares complete learning procedures, not isolated model names. The baseline and candidate must share the prediction timestamp, allowed features, target definition, evaluation cases and metric. A simple baseline can be strong when most variation is predictable from a stable group or season. A complex candidate can appear superior by using information unavailable when the decision must be made.
Separate fitting, model selection and final evaluation. Hyperparameters chosen after looking at test results make those results development evidence. Reproducibility includes the split rule and selection history, not just a seed.
Worked problem Training targets are [10,20,30]. An unseen test contains [15,35]. Compare the training-mean baseline with predictions [18,30] using mean absolute error.
Step-by-step reasoning 1. The baseline is 20, calculated from training only. Test absolute errors are 5 and 15, so MAE=10.
- Candidate errors are 3 and 5, so MAE=4. The observed improvement is 6 units on these two cases.
- The candidate’s relative error reduction is 60%, but two cases do not establish stable population performance. Examine uncertainty and case selection.
- Confirm the candidate used no final outcomes or post-decision features. Equal metrics do not repair unequal information.
Apply the idea
Training targets are [10,20,30]. An unseen test contains [15,35]. Compare the training-mean baseline with predictions [18,30] using mean absolute error.
The candidate used final payment date to predict lateness at invoice creation. What changes in the conclusion even though its MAE is smaller?
Read the worked reasoning
The feature is unavailable at the prediction timestamp, so the comparison does not establish deployable improvement. Remove that information, refit using development data, and evaluate the revised procedure. Report the corrected outcome rather than preserving the original improvement claim. The arithmetic remains correct for a retrospective task but answers the wrong decision.
Check understanding
What makes a baseline useful?
- It tests whether model complexity adds task-relevant value
Feedback
A transparent reference exposes weak or misleading gains.
- It must always be a neural network
Feedback
A baseline is usually deliberately simple.
- It should be fitted on test outcomes
Feedback
Test targets must not shape the fitted reference.
Further reading
Study the complete on-site source sections below, then work the original example, changed-condition problem and transfer laboratory. Study scikit-learn Getting Started, Model Selection and Common Pitfalls; Dive into Deep Learning Introduction and Generalization. Define one prediction task before choosing a model.