Aan de slagGa gratis aan de slag

Choosing the best model

In this exercise, you'll compare different classifiers and choose the one that performs the best.

The dataset here - already loaded and split into train and test sets - consists of Pokémon - their stats, types, and whether or not they're legendary. The objective of our classifiers is to predict this 'Legendary' variable.

Three individual classifiers have been fitted to the training set:

  • clf_lr is a logistic regression.
  • clf_dt is a decision tree.
  • clf_knn is a 5-nearest neighbors classifier.

As the classes here are imbalanced - only 65 of the 800 Pokémon in the dataset are legendary - we'll use F1-Score to evaluate the performance. Scikit-learn's f1_score() has been imported for you.

Deze oefening maakt deel uit van de cursus

Ensemble Methods in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Predict the labels of the test set
pred_lr = ____
pred_dt = ____
pred_knn = ____
Code bewerken en uitvoeren