AI 301 — Machine Learning, Neural Networks and Language · Weeks 1–2
Problem formulation, baselines and honest experiments
Full teaching sequence and cumulative subject work
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.
A baseline must receive the same information
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.
Trace the complete reasoning
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.
Independent transfer problem
The candidate used final payment date to predict lateness at invoice creation. What changes in the conclusion even though its MAE is smaller?
Compare the transfer solution
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.
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.
Study the mechanism
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 example
train_y = [10, 20, 30]
test_y = [15, 25]
baseline = sum(train_y) / len(train_y)
mae = sum(abs(y - baseline) for y in test_y) / len(test_y)
assert baseline == 20
assert mae == 5The 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.
Check your understanding
What makes a baseline useful?
- It tests whether model complexity adds task-relevant value
- It must always be a neural network
- It should be fitted on test outcomes
Answer and reasoning for every option
Correct: It tests whether model complexity adds task-relevant value A transparent reference exposes weak or misleading gains.
Reconsider: It must always be a neural network A baseline is usually deliberately simple.
Reconsider: It should be fitted on test outcomes Test targets must not shape the fitted reference.
Transfer laboratory: A baseline with unequal information
A neural model uses final payment status while the baseline uses only information known at invoice creation. Explain why the comparison cannot establish deployable improvement.
Work through the full solution
The candidate has an unavailable downstream feature, so it solves an easier retrospective problem. Reconstruct both models at the prediction timestamp and use identical allowed data and evaluation splits. Retune only in development. Report the corrected result even if the apparent advantage disappears; a more complex method is not entitled to a higher score.
Evidence of understanding
Equalize information availability before comparing model families.
Complete on-site teaching readings
These are full attributed source sections, not previews. Read them alongside the original Academy explanation and code.
- 1. Introduction · Aston Zhang, Zachary C. Lipton, Mu Li and Alexander J. Smola
- 3.6. Generalization Open the notebook in SageMaker Studio Lab · Aston Zhang, Zachary C. Lipton, Mu Li and Alexander J. Smola
- 3.1. Linear Regression Open the notebook in SageMaker Studio Lab · Aston Zhang, Zachary C. Lipton, Mu Li and Alexander J. Smola
- Getting Started · The scikit-learn developers
- 3.1. Cross-validation: evaluating estimator performance · The scikit-learn developers
- 12. Common pitfalls and recommended practices · The scikit-learn developers
Open the complete practice sequence and cumulative assessment →