IniziaInizia gratis

Predicting on the test set

In the last exercise, linear regression and ridge appeared to produce similar results. It would be appropriate to select either of those models; however, you can check predictive performance on the test set to see if either one can outperform the other.

You will use root mean squared error (RMSE) as the metric. The dictionary models, containing the names and instances of the two models, has been preloaded for you along with the training and target arrays X_train_scaled, X_test_scaled, y_train, and y_test.

Questo esercizio fa parte del corso

Supervised Learning with scikit-learn

Visualizza il corso

Istruzioni dell'esercizio

  • Import root_mean_squared_error.
  • Fit the model to the scaled training features and the training labels.
  • Make predictions using the scaled test features.
  • Calculate RMSE by passing the test set labels and the predicted labels.

Esercizio pratico interattivo

Prova questo esercizio completando il codice di esempio.

# Import root_mean_squared_error
from ____.____ import ____

for name, model in models.items():
  # Fit the model to the training data
  ____
  
  # Make predictions on the test set
  y_pred = ____
  
  # Calculate the test_rmse
  test_rmse = ____(____, ____)
  print("{} Test Set RMSE: {}".format(name, test_rmse))
Modifica ed esegui il codice