in Python Flask by
Build a K-nearest neighbors classification model from scratch with the following conditions:

1 Answer

0 votes
by

Use Euclidean distance (aka, the “2 norm”) as your closeness metric.

Your function should be able to handle data frames of arbitrarily many rows and columns.

If there is a tie in the class of the k nearest neighbors, rerun the search using k-1 neighbors instead.

You may use pandas and numpy but NOT scikit-learn.

Example Output:

def kNN(k,data,new_point) -> 2

...