Vectorized 1-Nearest-Neighbor in NumPy and Its Equivalence to a Linear Layer

Quick Overview

Implement a 1-nearest-neighbor classifier in NumPy using only vectorized operations, then show that finding the nearest training point is equivalent to an argmax over a linear layer W x + b built from the training data. It tests broadcasting, the expanded L2 distance, memory limits and numerical stability.

Vectorized 1-Nearest-Neighbor in NumPy and Its Equivalence to a Linear Layer

Company: OpenAI

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: hard

Interview Round: Onsite

Overview: Implement a 1-nearest-neighbor classifier in NumPy using only vectorized operations, then show that finding the nearest training point is equivalent to an argmax over a linear layer W x + b built from the training data. It tests broadcasting, the expanded L2 distance, memory limits and numerical stability.

OpenAI logo
OpenAI
Sep 20, 2026
hardMachine Learning EngineerOnsiteMachine Learning
13
0
Loading...