Verified interview challenge
Implement K-nearest neighbours
Build a small classifier that predicts a query's label from its nearest training examples.
Unlock with Full AccessThe challenge
Work directly with numeric training vectors and their labels rather than a ready-made classifier. Identify the nearest examples for a query and combine their votes under the specified tie rule. The challenge focuses on translating the algorithm into a correct implementation across valid input sizes and dimensions.
What you'll practise
Neighbour selection
Compute distances and keep the selected points paired with their labels.
Deterministic prediction
Handle the vote count and its boundary cases according to the contract.
# Your implementation goes here
# Run examples and inspect results
# Full starter code includedRun your code to see results.