1. Learn
  2. /
  3. Courses
  4. /
  5. Designing Machine Learning Workflows in Python

Connected

Exercise

Grid search CV for model complexity

In the last slide, you saw how most classifiers have one or more hyperparameters that control its complexity. You also learned to tune them using GridSearchCV(). In this exercise, you will perfect this skill. You will experiment with:

  • The number of trees, n_estimators, in a RandomForestClassifier.
  • The maximum depth, max_depth, of the decision trees used in an AdaBoostClassifier.
  • The number of nearest neighbors, n_neighbors, in KNeighborsClassifier.

Instructions 1/3

undefined XP
  • 1

    Define the parameter grid as described in the code comment and create a grid object with a RandomForestClassifier().

  • 2

    Adapt your code to optimise n_estimators for an AdaBoostClassifier().

  • 3

    Adapt your code to optimise n_neighbors for an KNeighborsClassifier().