RMSE Step-by-step
In this exercise, you will quantify the over-all model "goodness-of-fit" of a pre-built model, by computing one of the most common quantitative measures of model quality, the RMSE, step-by-step.
Start with the pre-loaded data x_data and y_data, and use it with a predefined modeling function model_fit_and_predict().

Cet exercice fait partie du cours
Introduction to Linear Modeling in Python
Instructions
- Compute
y_modelvalues frommodel_fit_and_predict(x_data, y_data). - Compute the
residualsas the difference betweeny_modelandy_data. - Use
np.sum()andnp.square()to computeRSS, and divide bylen(residuals)to getMSE. - Take the
np.sqrt()ofMSEto getRMSE, and print all results.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Build the model and compute the residuals "model - data"
y_model = model_fit_and_predict(x_data, y_data)
residuals = ____ - ____
# Compute the RSS, MSE, and RMSE and print the results
RSS = np.____(np.____(residuals))
MSE = ____/len(residuals)
RMSE = np.____(____)
print('RMSE = {:0.2f}, MSE = {:0.2f}, RSS = {:0.2f}'.format(RMSE, MSE, RSS))