Skip to content

Instantly share code, notes, and snippets.

View sameersyd's full-sized avatar
🪄
Magic w/ Code

Sameer Nawaz sameersyd

🪄
Magic w/ Code
View GitHub Profile
from collections import Counter
import math
def knn(data, query, k, distance_fn, choice_fn):
neighbor_distances_and_indices = []
# 3. For each example in the data
for index, example in enumerate(data):
# 3.1 Calculate the distance between the query example and the current
# example from the data.