Created
March 21, 2021 19:27
-
-
Save kino6052/3b8468bb0246889151d5cbb7940b4252 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = np.array([[1, 1],[1, 2],[1, 3]]) ## must contain first column with one for theta bias | |
y = np.array([[4.5], [5.5], [8.5]]) | |
_x = np.dot(x.T, x) | |
xI = np.linalg.inv(_x) | |
n = np.dot(xI,x.T) | |
theta = np.dot(n, y) | |
print(theta) | |
print(theta[0], theta[0][0]) | |
print(x[0], x[0][0]) | |
y1_hat = theta[0][0] + theta[1][0]*x[0][1] | |
print(y1_hat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment