5.1. Exercises

Name That Measurement!

True or False: Regression Measurements

Calculating โ€œby handโ€

Observation True Value Predicted Value
0 4 5
1 12 10
2 6 9
3 9 8
4 3 3

Calculating Regression Measurements

Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.

When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.

Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line wonโ€™t execute and you can test your code after each step.

Letโ€™s calculate some measurements from our basketball dataset this time predicting the playersโ€™ salary. How well does our model do?

Tasks:

  • Calculate the MSE, RMSE, Rs2, and MAP measurement by comparing the true values to what the model predicted on the validation set. Name the objects mse_calc, rmse_calc, re_calc and mape_calc respectively.
Hint 1
  • Are you using the arguments y_valid and predict_valid for your calculations?
  • Are you using np.sqrt() on your mse_calc to calculate rmse_calc?
  • Are you using np.mean(np.abs((predict_valid - y_valid) / y_valid)) * 100.0 to calculate mape_calc?
Fully worked solution: