k-NN is the classifier with no training step and two places to get wrong: what happens when two candidates are exactly the same distance away, and what happens when the vote itself is tied.
Write knn_predict(X_train, y_train, X_query, k). For every row of X_query, predict the majority class among its k nearest neighbours in X_train by Euclidean distance.
X_train — whichever one appeared first is treated as strictly nearer.k neighbours' labels is broken by the smallest class label.Both rules exist for the same reason: run this twice on the same input and get the same answer twice, with no dependency on how ties happened to be ordered internally.
Return an (m,) integer array of predicted labels, one per query row.
Build the architecture on a canvas: place the components, configure them, connect them into a data flow, and write a short reason for each one. The AI reviewer grades your design against a rubric written specifically for this problem.
Minimum 5 components · needs a wide desktop screen