Created
April 30, 2022 04:08
-
-
Save hucodelab/58e46cff722847159fd92c64d6e1247c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # let's test several parameters | |
| n_neighbors = [1,5,10,20,50,100] | |
| test_accuracy = {} | |
| train_accuracy = {} | |
| for n in n_neighbors: | |
| clf = KNeighborsClassifier(n_neighbors = n) | |
| clf.fit(X_train,y_train) | |
| test_acc=clf.score(X_test,y_test) | |
| training_acc=clf.score(X_train, y_train) | |
| test_accuracy[n] = test_acc | |
| train_accuracy[n] = training_acc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment