Exercise

Hyperparameters of KNN

To apply the concepts learned in the prior exercise, it is good practice to try out learnings on a new algorithm. The k-nearest-neighbors algorithm is not as popular as it used to be but can still be an excellent choice for data that has groups of data that behave similarly. Could this be the case for our credit card users?

In this case you will try out several different values for one of the core hyperparameters for the knn algorithm and compare performance.

You will have available:

  • X_train, X_test, y_train, y_test DataFrames

Instructions

100 XP
  • Build a knn estimator for the following values of n_neighbors [5,10,20].
  • Fit each to the training data and produce predictions.
  • Get an accuracy score for each model and print them out.