MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Supervised Learning with scikit-learn

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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(____))
Edit dan Jalankan Kode