Question: def gradientDescent (X, y, theta, alpha, num_iters): This function returns a tuple (theta, cost_array) m len(y) cost array - for i in range(0, num_iters): START


def gradientDescent (X, y, theta, alpha, num_iters): This function returns a tuple (theta, cost_array) m len(y) cost array - for i in range(0, num_iters): START TODO # Make predictions # Hint: y.hat = theta-0 + (theta-1 * x_1 ) + (theta-2 * x-2) # Shape of y-hat: m by 1 Y_hat- # Compute the difference between predictions and true values # Shape of residuals: m by 1 residuals y_hat-y # Calculate the current cost cost = cost_array.append(cost) # Compute gradients # Shape of gradients: 3 by 1, i.e., same as theta gradients # Update theta theta return theta, cost_array
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
