Sequential Model-Based Optimization using K-Nearest Neighbors

Learn to apply the sequential model-based optimization method (SMBO) to find the best hyperparameters for a K-nearest neighbors model.

This example shows how we can use the SMBO method to optimize the hyperparameters of the ML model.

In this example, we’ll use the k-nearest neighbors (KNN) algorithm to determine which combination of hyperparameter values will produce the best results compared to the results obtained by using the default values for the hyperparameters.

What will we learn?

In this lesson, we’ll learn how to do the following things in the Jupyter Notebook:

  • Create and train an ML model (KNN).

  • Measure the performance of the ML model.

  • Perform the steps required to implement the SMBO method.

  • Identify the combination of hyperparameters that provide the best results.

Import the important packages

First, we import the important Python packages that will perform the following tasks:

  • Create and train an ML model (KNN algorithm).

  • Check ML model performance.

  • Implement the SMBO method.

  • Identify a combination of hyperparameters that provide the best results.

Get hands-on with 1400+ tech skills courses.