Finalizing an XGBoost model
It's time to build a robust XGBoost model to add to the pipeline. Go ahead and import XGBRegressor
, numpy
, GridSearchCV
, cross_val_score
, KFold
, and mean_squared_error
as follows:
import numpy as np from sklearn.model_selection import GridSearchCV from sklearn.model_selection import cross_val_score, KFold from sklearn.metrics import mean_squared_error as MSE from xgboost import XGBRegressor
Now let's build the model.
First XGBoost model
This Student Performance dataset has an interesting range of values for the predictor column, y_train
, which can be shown as follows:
y_train.value_counts()
The result is this:
11 82 10 75 13 58 12 53 14 42 15 36 9 29 16 27 8 26 17 24 18 ...