Python, R Programming, R, Linear Algebra, Calculus.
as np def gradient_descent(X, y, alpha, num_iters): m = len(y) theta = np.zeros((2, 1)) for i in range(num_iters): h = np.dot(X, theta) loss = h - y gradient = np.dot(X.T, loss) / m theta = theta - alpha * gradient return theta X = np.array([[1, 2], [1, 3], [1, 4], [1, 5]]) y = np.array([[2], [4],