title: Machine Learning Gradient descent python implementation
body: <h3>Problem</h3>
  
  <p>I have written this code, but this is giving errors:</p>
  
  <blockquote>
    <p>RuntimeWarning: overflow encountered in multiply</p>
  
  <pre><code>t2_temp = sum(x*(y_temp - y))
  </code></pre>
    
    <p>RuntimeWarning: overflow encountered in double_scalars</p>
  
  <pre><code>t1_temp =  sum(y_temp - y)
  </code></pre>
  </blockquote>
  
  <p>Should I use feature scaling or is there something wrong in my code?</p>
  
  <h3>Code</h3>
  
  <pre><code>import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  
  def gradient_descent(x,y,t1,t2,repeat,alpha):
      n = x.size
      for i in range(repeat):
          y_temp = x*t2 + t1
          t1_temp =  sum(y_temp - y)
          t2_temp = sum(x*(y_temp - y))
          t1 = t1 - alpha * (t1_temp/n)
          t2 = t2 - alpha * (t2_temp/n)
  
      return [t1,t2]
  
  
  d = pd.read_csv("train.csv")
  
  x = d['GrLivArea']
  y = d['SalePrice']
  
  x = (np.array(x.values))
  y = (np.array(y.values))
  
  
  alpha = 0.047
  repeat = 3000
  
  theta = [1.23154644,1.654132398]
  
  tt = gradient_descent(x,y,theta[0],theta[1],repeat,alpha)
  
  print("FINISH")
  </code></pre>