Evaluate individual classifiers
In this exercise you'll evaluate the performance of the models in the list classifiers that we defined in the previous exercise. You'll do so by fitting each classifier on the training set and evaluating its test set accuracy.
The dataset is already loaded and preprocessed for you (numerical features are standardized) and it is split into 70% train and 30% test. The features 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 loaded the list classifiers from the previous exercise, as well as the function accuracy_score() from sklearn.metrics.
Deze oefening maakt deel uit van de cursus
Machine Learning with Tree-Based Models in Python
Oefeninstructies
- Iterate over the tuples in
classifiers. Useclf_nameandclfas theforloop variables:- Fit
clfto the training set. - Predict
clf's test set labels and assign the results toy_pred. - Evaluate the test set accuracy of
clfand print the result.
- Fit
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Iterate over the pre-defined list of classifiers
for clf_name, clf in ____:
# Fit clf to the training set
____.____(____, ____)
# Predict y_pred
y_pred = ____.____(____)
# Calculate accuracy
accuracy = ____(____, ____)
# Evaluate clf's accuracy on the test set
print('{:s} : {:.3f}'.format(clf_name, accuracy))