Aan de slagGa gratis aan de slag

Regression performance

Now you have fit a model, reg, using all features from sales_df, and made predictions of sales values, you can evaluate performance using some common regression metrics.

The variables X_train, X_test, y_train, y_test, and y_pred, along with the fitted model, reg, all from the last exercise, have been preloaded for you.

Your task is to find out how well the features can explain the variance in the target values, along with assessing the model's ability to make predictions on unseen data.

Deze oefening maakt deel uit van de cursus

Supervised Learning with scikit-learn

Cursus bekijken

Oefeninstructies

  • Import root_mean_squared_error.
  • Calculate the model's R-squared score by passing the test feature values and the test target values to an appropriate method.
  • Calculate the model's root mean squared error using y_test and y_pred.
  • Print r_squared and rmse.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import root_mean_squared_error
from ____.____ import ____

# Compute R-squared
r_squared = reg.____(____, ____)

# Compute RMSE
rmse = ____(____, ____)

# Print the metrics
print("R^2: {}".format(____))
print("RMSE: {}".format(____))
Code bewerken en uitvoeren