IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Machine Learning with Tree-Based Models in Python

Visualizza il corso

Istruzioni dell'esercizio

  • Fit bc to the training set.

  • Predict the test set labels and assign the result to y_pred.

  • Determine bc's test set accuracy.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# 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)) 
Modifica ed esegui il codice