title: Numpy error while defining gradient descent function
body: <pre><code># Reading the dataset
  data= pd.read_csv("energydata_complete.csv")
  X = data.drop(['Appliances','date'], axis=1)
  Y = data['Appliances'].values
  y_np = Y.shape[0]
  y = Y.reshape(y_np,1)
  L = 0.001
  
  n = X.shape[1]
  m = y.size
  ones = np.ones((X.shape[0],1))
  X = np.concatenate((ones,X), axis = 1)
  X = X.astype("float64")
  y = y.astype("float64")
  thetas = np.random.random([1,n+1])
  
  
  
  # Splitting data into training and testing
  from sklearn.model_selection import train_test_split
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size =
  0.25, random_state = 5)
  
  # Partition the dataset in train + validation sets
  from sklearn.preprocessing import MinMaxScaler
  scaler = MinMaxScaler()
  X_train = scaler.fit_transform(X_train)
  
  
  def batch_grad_desc(X,y,m,thetas,L):
      cost_list = []
      thetas_list = []
      L = 0.001
      L = []
      m = y.size
  
      y_hat_list = []
      grad = True
      i = 0
  
      cost_list.append (1e10)
  
      while grad:
          y_hat = np.dot(X,thetas.T)
          y_hat_list.append(y_hat)
          Error = (y_hat - y)
          cost = 1/(2*m) * np.dot(Error.T, Error)
  
          cost_list.append(cost)
          thetas = thetas - (L*(1/m) * np.dot(X.T, Error))
  
          thetas_list.append(thetas)
  
          if cost_list - cost_list[i+1] &lt; 1e-9:
              grad = False
  
          i+= 1
      cost_list.pop(0)
  
      return y_hat_list, cost_list, thetas_list
  
  
  y_hat_list, cost_list, thetas_list = batch_grad_desc(X, y, m, thetas, L)
  thetas = thetas_list[-1]
  </code></pre>
  
  <p>Error:</p>
  
  <pre class="lang-none prettyprint-override"><code>    TypeErrorTraceback (most recent call last)
  &lt;ipython-input-66-5b85a5574e32&gt; in &lt;module&gt;
  ----&gt; 1 y_hat_list, cost_list, thetas_list = batch_grad_desc(X, y, m, `thetas, L)`
        2 thetas = thetas_list[-1]
  
  &lt;ipython-input-65-9097ee62fbd8&gt; in batch_grad_desc(X, y, m, thetas, L)
           19
           20         cost_list.append(cost)
      ---&gt; 21         thetas = thetas - (L*(1/m) * np.dot(X.T, Error))
           22
           23         thetas_list.append(thetas)
  
  TypeError: can't multiply sequence by non-int of type 'float'
  </code></pre>
  
  <p>I have implemented a basic batch gradient function but now I am getting error where I am updating theta and I am unable to guess how to make it work. The variables are already declared in float. I do not know what the error is all about?</p>