I am trying to create a function that will calculate mean squared error from y (true values) and y_pred (predicted ones) not using sklearn or other implementations.

I'll try next:

def mserror(y, y_pred):

i=0

for i in range (len(y)):

i+=1

mse = ((y - y_pred) ** 2).mean(y)

return mse

How to fix it?