Evaluate Bagging performance
Now that you instantiated the bagging classifier, it's time to train it and evaluate its test set accuracy.
The Indian Liver Patient dataset is processed for you and split into 80% train and 20% test. The feature matrices X_train
and X_test
, as well as the arrays of labels y_train
and y_test
are available in your workspace. In addition, we have also loaded the bagging classifier bc
that you instantiated in the previous exercise and the function accuracy_score()
from sklearn.metrics
.
This exercise is part of the course
Machine Learning with Tree-Based Models in Python
Exercise instructions
Fit
bc
to the training set.Predict the test set labels and assign the result to
y_pred
.Determine
bc
's test set accuracy.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Fit bc to the training set
____.____(____, ____)
# Predict test set labels
y_pred = ____.____(____)
# Evaluate acc_test
acc_test = ____(____, ____)
print('Test set accuracy of bc: {:.2f}'.format(acc_test))