<jupyter_start><jupyter_text>Applying Gradient Descent Algorithm from scratch for Univariate Linear Regression<jupyter_code>#gradient Descent Algorithm

theta_zero = 0
theta_one  = 0

learningRate = 0.001
iterations = 100
n = len(X)
for i in range(n):
    pred_Y = theta_one*X + theta_zero
    D_theta_zero = (-2/n) * sum(Y - pred_Y)
    D_theta_one  = (-2/n) * sum( X * (Y - pred_Y))
    theta_zero   = theta_zero - learningRate * D_theta_zero
    theta_one    = theta_one  - learningRate * D_theta_one


print(theta_zero, theta_one)
predicted_Y = theta_zero + theta_one * X
plt.scatter(X,Y)
plt.plot([min(X),max(X)] ,[min(predicted_Y), max(predicted_Y)], color='Green')
plt.xlabel('Population of City in 10,000s')
plt.ylabel('Profit in $10,000s')
plt.show()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup