Mathematical calculations
np.power
def ComputeCost(X, y, theta):
inner = np.power(((X * theta.T) - y), 2)
cost = np.sum(inner) / (2 * len(X))
return cost
Matrix operations
np.matrix
X = np.matrix(X)
y = np.matrix(y)
#X = np.matrix(X.values)
#y = np.matrix(y.values)
theta = np.matrix(np.array([0,0]))
temp = np.matrix(np.zeros(theta.shape))
X.shape, y.shape, theta.shape