Neuron 101

Learning from examples / Multiple linear regression

Türkçe

Plate29

Unit 3 · Topic 8 of 11

Multiple linear regression

Medium, 8 min, 8 steps

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

Step 1 of 8 One

The one-feature line

So far we only looked at temperature. The least squares line is sales = 1.59 · temperature + 4.43, with a loss of 4.31.

Open in Colab
  1. import numpy as np
  2. x = np.array([12, 15, 18, 20,
  3. 23, 26, 29, 32])
  4. h = np.array([0, 0, 1, 0, 0, 1, 0, 1])
  5. y = np.array([25, 26, 35, 33,
  6. 42, 48, 48, 56])
  7. X = np.c_[np.ones(8), x, h]
  8. A, c = X.T @ X, X.T @ y
  9. b, w1, w2 = np.linalg.solve(A, c)
  10. print(w1, w2, b)
w1
1.48
w2
3.33
b
5.44
mse
2.16