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.
Questo esercizio fa parte del corso
Supervised Learning with scikit-learn
Istruzioni dell'esercizio
- 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
andy_pred
. - Print
r_squared
andrmse
.
Esercizio pratico interattivo
Prova questo esercizio completando il codice di esempio.
# 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(____))