Skip to content

Instantly share code, notes, and snippets.

@jurand71
Created November 16, 2022 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jurand71/46c1a5bb8d8d57e58cb327ce1130f669 to your computer and use it in GitHub Desktop.
Save jurand71/46c1a5bb8d8d57e58cb327ce1130f669 to your computer and use it in GitHub Desktop.
print("Dokładność modelu dla k=1")
classifier = KNearestNeighbor()
classifier.train(X_train, y_train)
dists = classifier.compute_distances_no_loops(X_test)
y_pred = classifier.predict_labels(dists, k=1)
num_correct = np.sum(y_pred == y_test)
num_test = X_test.shape[0]
accuracy = float(num_correct) / num_test
print('Poprawnie zidentyfikowano %d na %d obrazów testowych => dokładność: %f' % (num_correct, num_test, accuracy))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment