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