Session Ready
Exercise

Calculating R-squared

The R-squared of a model evaluated on input data is the variance of the model output divided by the variance of the response variable in the input data. Note that to calculate R-squared, you need input data that has the actual value of the response variable. The training data are used for this purpose.

The code provided in the editor reminds you how to calculate prediction errors and how to find the variance of the response variable in the input data. Use these two calculations to find R-squared for each of the models.

Instructions
100 XP
  • Train the three models provided in the editor.
  • Evaluate each of the models on its own training data.
  • Find the ratio of the variance of model output to the variance of the actual response values.