Training k-nearest neighbors for our model

  1. Load the scikit-learn KNN classification model and print the docstring by running the cell containing the following code:
      from sklearn.neighbors import KNeighborsClassifier      KNeighborsClassifier?

The n_neighbors parameter decides how many samples to use when making a classification. If the weights parameter is set to uniform, then class labels are decided by majority vote. Another useful choice for the weights is distance, where closer samples have a higher weight in the voting. Like most model parameters, the best choice for this depends on the particular dataset.

  1. Train the KNN classifier with n_neighbors=3, and then compute the accuracy and decision regions. Run the cell containing the following ...

Get Applied Deep Learning with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.