Variables and datasets. Models and hypotheses. Generalization.
Formulating a regression task
We have chosen a supervised regression task.
How is one observation recorded?
Which prediction functions may we use?
How do we judge their predictions?

| Trial i | Fertilizer xᵢ | Yield yᵢ |
|---|---|---|
| 1 | 0.0000 | 1.9200 |
Here fertilizer is the predictor (input); yield is the outcome (target).
| Trial i | Fertilizer X₁ | Soil moisture X₂ | Yield Y |
|---|---|---|---|
| 1 | 0.2 | 0.4 | 0.8 |
| 2 | 0.6 | 0.5 | 1.1 |
| 3 | 0.9 | 0.3 | 0.7 |
X₁ and X₂ name the inputs; Y names the outcome.
y₂ = 1.1: the measured yield of trial 2.
| Trial i | Fertilizer xᵢ | Yield yᵢ |
|---|---|---|
| 1 | 0.0000 | 1.9200 |
| 2 | 0.0417 | 1.7144 |
| 3 | 0.0833 | 2.0449 |
Example domains for fertilizer and measured soil moisture.
| Record | Fertilizer | Soil moisture | Yield |
|---|---|---|---|
| 1 | 0.2 | 0.4 | 0.8 |
| 2 | 0.6 | 0.5 | 1.1 |
| 3 | 0.9 | 0.3 | 0.7 |
Fertilizer first, soil moisture second.
Toy inputs: fertilizer, then soil moisture; one row per trial.
Measured yield for each trial, in the same row order.
X ∈ ℝn×m: n rows and m predictor columns.
Y ∈ ℝⁿ: one target for each input row.
Each point is one field trial: x = fertilizer level, y = measured yield. Both use the original course scale. Inspect any of the 25 points; drag to zoom or use Pan and Reset view.
Keep this form fixed. A hypothesis θ chooses numerical values for a, b and c.
Every real triple (a, b, c) is allowed in this quadratic family.
This tuple selects one candidate function.
x = fertilizer input; y = measured yield; ŷ = curve prediction. Residual = y − ŷ; MSE = average squared residual. The supplied curve has no specified model family.
Could another hypothesis fit these observations better?
How can we measure fit when a plot is impractical, for example with many predictors?
Observed minus predicted.
Square the gaps, add them and divide by n.
Synthetic example: x = input, y = outcome. Degree sets the polynomial’s highest power; σ sets noise standard deviation. MSE averages squared prediction errors. The seed repeats the sample.
80 trials have four predictors, a lookup ID and a target. What is the shape of X? Does the ID belong in it?
Changing θ from (1,0,0) to (2,−1,0.5) changes signs. Does it require a different quadratic family?
In a toy case, observed yield is 4 kg and prediction is 6 kg. What does the residual mean? What units does its square have?
Predict later months for fields never used in training. Which dates and field identities should be held out?
X is 80 × 4; Y has 80 targets. A lookup ID does not become a predictor just because it is stored.
Both tuples are in Θ = ℝ³. Negative coefficients are allowed; the functional form stays quadratic.
r = 4 − 6 = −2 kg. The prediction is too high. Squaring gives 4 kg².
Train on earlier dates from one group of fields; evaluate later dates from other fields.
What is observed, and which outcome is predicted?
Pairs in 𝓓; predictor rows in X; targets in Y.
A function family and its allowed parameter space Θ.
Select θ using training observations.
Use validation evidence for model selection.
Estimate new-case performance on a held-out test.
Introduction to Machine Learning · original course lesson
The variable, dataset and hypothesis definitions, and the two original fertilizer charts.
scikit-learn · Common pitfalls and data leakage
Training-only preprocessing and appropriate held-out evaluation.
Lecture 08 · Introduction to machine learning · Part 2