Learning, and the capstone · University · about 35 min
Held-out data, overfitting, and choosing a model by the error it makes on points it never saw.
[1 mark]A degree 5 polynomial through six noisy speed measurements has zero training error. What has it learned?
[1 mark]A line is fitted to the three training points and scored by RMS error on both sets. What does this print?
train = [(30, 5.8), (50, 9.9), (70, 14.1)]
test = [(40, 8.2), (60, 11.7), (80, 16.3)]
n = len(train)
sx = sum(c for c, v in train)
sv = sum(v for c, v in train)
sxx = sum(c * c for c, v in train)
sxv = sum(c * v for c, v in train)
a = (n * sxv - sx * sv) / (n * sxx - sx * sx)
b = (sv - a * sx) / n
def rms(points):
return (sum((a * c + b - v) ** 2 for c, v in points) / len(points)) ** 0.5
print(round(rms(train), 3), round(rms(test), 3))[1 mark]A student compares five models by their test error, picks the best, and reports that same test error as the result. What is wrong?
[1 mark]With very little data, what method splits the data into k parts, fits k times leaving each part out in turn, and averages the held-out errors?
[1 mark]Which statements about bias and variance are right?
Tick every answer that is true.
[1 mark]Why scale commands, u = (c - 55) / 25, before fitting a high degree polynomial by the normal equations?
[1 mark]Two models score nearly the same held-out error, one degree 1 and one degree 3. Which should you choose, and why?
Sample fourteen commands, six for training and eight for testing, fit a degree 1 and a degree 5 model to the training six, print all four errors, and print train 5: and best degree:. Three of the test commands, 25, 85 and 95, lie outside the training range, which is where an overfitted model is at its worst.
from bugbot import * connect() DT = 0.1 TRAIN = [30, 40, 50, 60, 70, 80] TEST = [25, 35, 45, 55, 65, 75, 85, 95]
Plan your program here, then type it in and press Run.