Skip to content

Instantly share code, notes, and snippets.

@purva91
Last active August 10, 2020 08:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save purva91/037c83e2d4277785f0e196fcd767dfdd to your computer and use it in GitHub Desktop.
train_score = []
test_score = []
k_vals = []
for k in range(1, 21):
k_vals.append(k)
knn = KNeighborsClassifier(n_neighbors = k)
knn.fit(X_train, y_train)
tr_score = knn.score(X_train, y_train)
train_score.append(tr_score)
te_score = knn.score(X_test, y_test)
test_score.append(te_score)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment