1. Apprendre
  2. /
  3. Cours
  4. /
  5. Model Validation in Python

Connected

Exercice

Mean squared error

Let's focus on the 2017 NBA predictions again. Every year, there are at least a couple of NBA teams that win way more games than expected. If you use the MAE, this accuracy metric does not reflect the bad predictions as much as if you use the MSE. Squaring the large errors from bad predictions will make the accuracy look worse.

In this example, NBA executives want to better predict team wins. You will use the mean squared error to calculate the prediction error. The actual wins are loaded as y_test and the predictions as predictions.

Instructions

100 XP
  • Manually calculate the MSE. $$ MSE = \frac{\sum_{i=1}^{n} (y_i - \hat{y}_i ) ^2 }{n} $$
  • Calculate the MSE using sklearn.