title: Implement gradient descent in python
body: <p>I am trying to implement gradient descent in python. Though my code is returning result by I think results I am getting are completely wrong. </p>
  
  <p>Here is the code I have written:</p>
  
  <pre><code>import numpy as np
  import pandas
  
  dataset = pandas.read_csv('D:\ML Data\house-prices-advanced-regression-techniques\\train.csv')
  
  X = np.empty((0, 1),int)
  Y = np.empty((0, 1), int)
  
  for i in range(dataset.shape[0]):
    X = np.append(X, dataset.at[i, 'LotArea'])
    Y = np.append(Y, dataset.at[i, 'SalePrice'])
  
  X = np.c_[np.ones(len(X)), X]
  Y = Y.reshape(len(Y), 1)
  
  def gradient_descent(X, Y, theta, iterations=100, learningRate=0.000001):
    m = len(X)
    for i in range(iterations):
      prediction = np.dot(X, theta)
      theta = theta - (1/m) * learningRate * (X.T.dot(prediction - Y))
  
    return theta
  
    theta = np.random.randn(2,1)
    theta = gradient_descent(X, Y, theta)
    print('theta',theta)
  </code></pre>
  
  <p>The result I get after running this program is:</p>
  
  <blockquote>
    <p>theta [[-5.23237458e+228]
     [-1.04560188e+233]]</p>
  </blockquote>
  
  <p>Which are very high values. Can someone point out the mistake I have made in implementation.</p>
  
  <p>Also, 2nd problem is I have to set value of learning rate very low (in this case i have set to 0.000001) to work other wise program throws an error.</p>
  
  <p>Please help me in diagnosis the problem.</p>