Skip to content

Instantly share code, notes, and snippets.

@angeris
Created May 28, 2018 05:35
Show Gist options
  • Save angeris/6f3ff05fa99b2b377fcf309bdc467512 to your computer and use it in GitHub Desktop.
Save angeris/6f3ff05fa99b2b377fcf309bdc467512 to your computer and use it in GitHub Desktop.
Learns the sum of two numbers. In response to an hn comment.
import numpy as np
X = np.array([
[1, 4],
[20, 35],
[8, 15]
])
y = np.array([3, 15, 7])
opt_theta = np.linalg.lstsq(X, y)
print(opt_theta[0])
# Prints [-1. 1.]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment