Making a prediction using XGBoost
You have your trained regression model and now need to use it to predict the output values based on the inputs in our test dataset. Follow these steps:
- Use the model to make predictions of house value based on the test dataset and put the answers into an array called
y_score
. Use thepredict
method and pass it to theX_test
dataset:y_score = housevalue_regressor.predict(X_test)
You now have a vector,
y_score
, with the model’s prediction of the housing value based on the inputs inX_test
. You’ll usey_score
in just a bit to check the accuracy of the model by comparingy_score
to the ground truthy_test
values.As before with the iris data in Chapter 2, if you want to predict a housing value based on data that is not in the test or training dataset, to do inference, you just pass the model the equivalent of one row of input data, and it will predict the housing value. Keep in mind that you must maintain the units used in the input...