Mathematical calculations

np.power

  1. def ComputeCost(X, y, theta):
  2. inner = np.power(((X * theta.T) - y), 2)
  3. cost = np.sum(inner) / (2 * len(X))
  4. return cost

Matrix operations

np.matrix

  1. X = np.matrix(X)
  2. y = np.matrix(y)
  3. #X = np.matrix(X.values)
  4. #y = np.matrix(y.values)
  5. theta = np.matrix(np.array([0,0]))
  6. temp = np.matrix(np.zeros(theta.shape))
  7. X.shape, y.shape, theta.shape