You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#Python Program to illustrate the method of Gradient Descent algorithm(which finds the coefficients and intercept for the best fit line or Regeression function)
import numpy as np
def gradient_descent(x,y):
m_curr = 0
b_curr = 0
n = len(x)
lr = 0.03
iteration = 1000
for i in range(iteration):
y_pred = m_curr * x + b_curr
#cost = (1/n)*sum([val**2 for val in (y-y_pred)]) //Alt method to calculate cost function