I fail to find the theta using this code.
I added plotting code to help visualize the issue.
Please, help me find the bug in this short block of code
Thanks
import numpy as np import matplotlib.pyplot as plt N = 20 def arr(n): return np.arange(n) + 1 def linear(features, y): x = np.vstack(features).T xT = np.transpose(x) xTx = xT.dot(x) return np.linalg.inv(xTx).dot(xT).dot(y) def plot(x, y, dots_y): plt.plot(x, y) plt.plot(x, dots_y, marker='o', linestyle=' ', color='r') plt.show() y = arr(N) ** 2 + 3 theta = linear((np.ones(N), arr(N), arr(N) ** 2), y) plot(arr(N), arr(N) ** theta[1] + theta[0], y) 

