Neuron 101

Learning from examples / Training, validation and test

Türkçe

Plate30

Unit 3 · Topic 9 of 11

Training, validation and test

Medium, 7 min, 8 steps

05101520253035010203040506070temperature, degreesice creams sold
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 8 Data

Fourteen days

The ice cream seller now has fourteen days. If we use all of them for learning, no days are left to measure how wrong the model will be on new days.

Open in Colab
  1. import numpy as np
  2. x = [12, 15, 18, 20, 23, 26, 29, 32]
  3. y = [25, 26, 35, 33, 42, 48, 48, 56]
  4. xd, yd = [16, 25, 31], [30, 44, 52]
  5. xt, yt = [13, 22, 28], [27, 38, 49]
  6. def mse(xs, ys, w, b):
  7. s = sum((c - (w * a + b)) ** 2
  8. for a, c in zip(xs, ys))
  9. return s / len(xs)
  10. w, b = np.polyfit(x, y, 1)
  11. print(mse(x, y, w, b))
  12. print(mse(xd, yd, w, b))
  13. print(mse(xt, yt, w, b))
w
1.59
b
4.43
egitim
4.31
dogrulama
0.87
test
1.86