Python function returning a 4x4 matrix instead of a floating number like in an equivalent Octave function in a Linear Regression problem
Change the compute_cost function to the following to match dimensions for matrix multiplications:
def compute_cost(X, y, theta):
    m = len(y)
    ans = np.dot(X.T, theta).T - y
    product = np.dot((1/(2*m)), np.dot(ans, ans.T))
    return product[0, 0]

Result for the data given:
32.0727338775
54.242455082

PS: one can simplify the transpose operations further..