Replicate loss function

Hi, I’m failing to replicate the MSE loss function used in Lesson 5 (movie recommendations).

I get 1.4 and gives 0.8. Why?

My code is:

from sklearn.metrics import mean_squared_error
pred_scores = ratings.iloc[val_idxs]
pred_scores["preds"] = preds
mean_squared_error(pred_scores["rating"], pred_scores["preds"])

Thanks in advance!

It depends a bit on what is in the pred_scores["rating"] and pred_scores["preds"] arrays. Are these one-hot encoded values?

You can also compute the MSE yourself and see what kind of result you get there. Something like:

((pred_scores["rating"] - pred_scores["preds"])**2).mean()