I have this least squares method, but I need it to obtain 10 dimensional data. This is from a practice text I'm learning from. I came up with this method for a two-dimensional data set. Now I need to have it work for a 10 dimensional one, but I'm totally stuck on it.
def least_squares(w):
cost = 0
for p in range(len(y)):
# get pth input/output pair
x_p = x[p]
y_p = y[p]
# form linear combination
c_p = w[0] + w[1] * x_p
# add least squares for this datapoint
cost += (c_p - y_p) ** 2
return cost
This is the result I should get after the edit
w = np.ones((11,1))
print (least_squares(w))
[ 7917.97952037]