End-to-End ML Project- Beginner friendly

92 / 95

Evaluating the model on the test set

Now that we have a well-trained model in our hands, let's evaluate its performance on the testing data. First, we'll need to preprocess the test data and make it in a format acceptable to our ML model.

Then we'll simply predict the target variable for our testing data and analyze the performance of our model on it.

  1. Drop the target variable from the testing data strat_test_set and store the output (predictors) in a variable named X_test.

  2. Store the target variable of our testing data strat_test_set in a variable named y_test using the copy() method of our DataFrame object.

  3. Transform the testing predictors X_test by passing it through our pipeline full_pipeline by using the transform() method. Don't call either the fit() or fit_transform() method for the testing data as you don't want to fit the pipeline with our testing data. Store the output in a variable named X_test_prepared.

  4. Get our model by using the attribute best_estimator_ on object grid_search and store it in a variable named final_model.

  5. Predict the target variable for our dataset X_test_prepared using the predict() method on our model final_model and store the output in a variable final_predictions.

  6. Calculate the RMSE value for our model and store it in a variable final_rmse.

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...