Setting up and training XGBoost
Now that you have explored the data and checked for problems that would require data cleaning, you are ready to work with XGBoost. Next, we’ll set up XGBoost to perform classification by using the measurement columns (sepal length
, sepal width
, petal length
, and petal width
) as inputs or X
instances and set the species as the output or y
:
- Set the input values for the training dataset:
X_train= training_data [[ 'sepal length (cm)','sepal width (cm)', 'petal length (cm)','petal width (cm)' ]] X_train.head()
This will give you the following output:
Figure 2.7 – Results of X_train.head()
- Set the output (answers) to the
Species
column.Now, we can set up the column with the output or
y
value. This is the answer or label for the model:y_train = training_data[['Species']] y_train.head()
This will give you...