Possible error in guided answer?

Not sure if there is a different, better way to submit my question. I believe there might be a minor error in the provided answer to the ‘Train and Test Model’ screen in the ‘Feature Selection’ mission.

Screen Link: https://app.dataquest.io/m/236/feature-selection/4/train-and-test-model

DQ Answer Code includes:

train_mse = mean_squared_error(train_predictions, train[target])
test_mse = mean_squared_error(test_predictions, clean_test[target])

However, I believe the correct arguments for the mean_squared_error are y_true followed by y_pred? Am I mistaken?


It’s not an error, per se.

The difference in use really doesn’t matter. The MSE is given by -

Whether you calculated it as

(y_i - \hat{y_i})^2 = (predictions - test[target])^2

or as

(\hat{y_i} - y_i)^2 = (test[target] - predictions)^2

The result would be the same since you square the difference.

We can say that they should be consistent about this, but it’s not that big of an issue with MSE as per me. You can provide feedback to them for this using the Contact Us button in the top-right of this page if you’d like to.

Thanks The_doctor, that makes sense. I was just confused by the presentation previously about argument order.


1 Like