Implement the nearest neighbor classifier