Aan de slagGa gratis aan de slag

OOB Score vs Test Set Score

Now that you instantiated bc, you will fit it to the training set and evaluate its test set and OOB accuracies.

The 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 classifier bc instantiated in the previous exercise and the function accuracy_score() from sklearn.metrics.

Deze oefening maakt deel uit van de cursus

Machine Learning with Tree-Based Models in Python

Cursus bekijken

Oefeninstructies

  • Fit bc to the training set and predict the test set labels and assign the results to y_pred.

  • Evaluate the test set accuracy acc_test by calling accuracy_score.

  • Evaluate bc's OOB accuracy acc_oob by extracting the attribute oob_score_ from bc.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Fit bc to the training set 
____.____(____, ____)

# Predict test set labels
y_pred = ____.____(____)

# Evaluate test set accuracy
acc_test = ____(____, ____)

# Evaluate OOB accuracy
acc_oob = ____.____

# Print acc_test and acc_oob
print('Test set accuracy: {:.3f}, OOB accuracy: {:.3f}'.format(acc_test, acc_oob))
Code bewerken en uitvoeren