Comparing models Compare k-nearest neighbors classifiers with k=1 and k=5 on the handwritten digits dataset, already loaded into the variables X_train, y_train, X_test and y_test. You can set k with the n_neighbors parameter when creating the KNeighborsClassifier object, which is also already imported into the environment. Which model achieves the best accuracy on the test data? Instructions 35 XP Possible answers k=1 k=5 Hint Create the two classifiers with KNeighborsClassifier(n_neighbors=1) and KNeighborsClassifier(n_neighbors=5). Then train them and evaluate their score.
The rest of this lesson is reserved for subscribers Create your free account to try the sample exercises, then upgrade to full access whenever you like.