I’ve been trying to subtract two matrices (not sure if they are really matrices since one of them is pandas series) but the result is not true. I added the code and outputs, how can I get the correct 200X1 shape result?
*X is 200×4 and w is 4×1
>Solution :
You can reshape y_hat :
y - y_hat.reshape(-1,1)
The reason you get (200,200) is because of numpy broadcasting, it treats y_hat as (1,200), so in order for the shapes to match, numpy broadcasts y into (200,200) and y_hat into (200,200) and then does the substraction.
