import numpy as np import pylab def plot_data(data, b, m): x = data[:, 0] y = data[:, 1] y_predict = m*x + b pylab.plot(x, y_predict, 'k-') pylab.plot(x, y, 'o') pylab.show() def gradient(data, initial_b, initial_m, learning_rate, num_iter): b = init…