K-nearest naakilersorneq algorithmiigaanni data punktortut saarneq. Python programmi siunertarneq qajaq.
Datanik nunatsinni: [[1,2],[2,4],[2,3],[3,5],[3,1],[5,5],[5,3],[6,1],[6,2],[6,4]]
Ilumoorutinga K-nearest neighbors algorithm-mi python-imik tunngasut illit katersorneqarnera data point-illu nunatsinni akornanni two categories-mi (0 nebo 1): 

```
import math

def knn(data, query, k, distance_fn, choice_fn):
    neighbor_distances_and_indices = []
    
    distance_fn= illorfiit pingasut query point-mik all data point-ikkut
    for index, point in enumerate(data):
        distance = distance_fn(point, query)
        neighbor_distances_and_indices.append((distance, index))
    
    sorted_neighbor_distances_and_indices = sorted(neighbor_distances_and_indices)
    
    k_nearest_distances_and_indices = sorted_neighbor_distances_and_indices[:k]
    
    k_nearest_labels = [data[i][-1] for distance, i in k_nearest_distances_and_indices]
    
    return choice_fn(k_nearest_labels)

def euclidean_distance(point1, point2):
    sum_squared_distance = 0
    for i in range(len(point1)):
        sum_squared_distance += math.pow(point1[i] - point2[i], 2)
    return math.sqrt(sum_squared_distance)

def majority_vote(labels):
    vote_counts = {}
    for label in labels:
        vote_counts[label] = vote_counts.get(label, 0) + 1
    winner = max(vote_counts.items(), key=lambda x:x[1])[0]
    return winner


example usage:
data = [[1,2,1],[2,4,1],[2,3,1],[3,5,1],[3,1,0],[5,5,0],[5,3,0],[6,1,0],[6,2,0],[6,4,0]]
query = [4,4]
k = 3
prediction = knn(data, query, k, distance_fn=euclidean_distance, choice_fn=majority_vote)
print(prediction)
```